/* =========================================================================
   Dealwatcher – modernes UI
   Theme-fähig (hell/dunkel via prefers-color-scheme), gleiche Klassennamen.
   ========================================================================= */

:root {
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Flächen */
  --bg: #eef1f6;
  --bg-grad-1: #e9edf5;
  --bg-grad-2: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-inset: #eef2f8;

  /* Text */
  --text: #1a1f29;
  --text-muted: #667085;
  --text-soft: #8a94a6;

  /* Linien */
  --border: #e3e8f0;
  --border-strong: #cfd6e2;

  /* Akzent */
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-contrast: #ffffff;

  /* Semantik */
  --good: #15803d;
  --good-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --info: #0369a1;
  --info-soft: #e0f2fe;

  /* Deal-Highlight */
  --deal: #b45309;
  --deal-bg: linear-gradient(90deg, #fff7e6, #ffedcc);
  --deal-border: #f5c26b;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08), 0 2px 4px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);
  --ring: 0 0 0 3px rgba(79, 70, 229, 0.18);

  color-scheme: light;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e14;
    --bg-grad-1: #0d1119;
    --bg-grad-2: #0a0d13;
    --surface: #151a23;
    --surface-2: #1a212c;
    --surface-inset: #10151d;

    --text: #e7ebf3;
    --text-muted: #9aa5b6;
    --text-soft: #6b7688;

    --border: #232b38;
    --border-strong: #313b4c;

    --accent: #7c7bff;
    --accent-hover: #9694ff;
    --accent-soft: #1e2030;
    --accent-contrast: #0b0e14;

    --good: #4ade80;
    --good-soft: #10281a;
    --warn: #fbbf24;
    --warn-soft: #2a2110;
    --bad: #f87171;
    --bad-soft: #2a1414;
    --info: #56b6f0;
    --info-soft: #0e2230;

    --deal: #fcd34d;
    --deal-bg: linear-gradient(90deg, #2a2110, #35290f);
    --deal-border: #7a5a1e;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
    --ring: 0 0 0 3px rgba(124, 123, 255, 0.28);

    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

/* Regeln wie ".banner { display: flex }" wuerden das hidden-Attribut sonst ueberstimmen -
   ausgeblendete Elemente waeren trotzdem sichtbar. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 100% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(1000px 500px at -10% 0%, var(--bg-grad-2), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a:hover {
  text-decoration: underline;
}

/* ---- Buttons ---------------------------------------------------------- */
button,
.button {
  --btn-bg: var(--surface);
  --btn-border: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  line-height: 1.15;
  transition: transform 0.06s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

button:hover,
.button:hover {
  border-color: var(--accent);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

button:active,
.button:active {
  transform: translateY(1px);
}

button:focus-visible,
.button:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-color: var(--accent);
}

/* Primäraktion: der erste Submit-Button einer .stack/.actions-Gruppe */
form.stack > button[type="submit"],
.actions > button[type="submit"]:first-of-type,
.model-picker > button[type="submit"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

form.stack > button[type="submit"]:hover,
.actions > button[type="submit"]:first-of-type:hover,
.model-picker > button[type="submit"]:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button.danger {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 35%, transparent);
  background: transparent;
}

button.danger:hover {
  background: var(--bad-soft);
  border-color: var(--bad);
}

/* ---- Topbar ----------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem clamp(1rem, 3vw, 2rem);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.brand::before {
  content: "";
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #22d3ee);
  box-shadow: var(--shadow-sm);
}

.brand:hover {
  text-decoration: none;
}

nav {
  display: flex;
  gap: 0.2rem;
  flex-wrap: wrap;
}

nav a {
  color: var(--text-muted);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.92rem;
  transition: background 0.15s ease, color 0.15s ease;
}

nav a:hover {
  background: var(--surface-inset);
  color: var(--text);
  text-decoration: none;
}

nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

main {
  width: min(1180px, calc(100vw - 2rem));
  margin: 1.5rem auto 4rem;
}

/* ---- Typografie ------------------------------------------------------- */
h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  font-weight: 800;
}

h2 {
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  font-weight: 700;
}

/* ---- Formulare -------------------------------------------------------- */
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-soft);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: var(--ring);
}

textarea {
  resize: vertical;
  min-height: 4.5rem;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ---- Tabellen --------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  font-weight: 700;
}

th,
td {
  text-align: left;
  padding: 0.7rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:hover td {
  background: var(--surface-2);
}

/* ---- Container -------------------------------------------------------- */
.toolbar,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow-sm);
}

.filters,
.inline,
.actions,
.split {
  display: flex;
  align-items: end;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.split {
  align-items: center;
  justify-content: space-between;
}

.check {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--text-muted);
}

.check input {
  width: auto;
  accent-color: var(--accent);
  width: 1.05rem;
  height: 1.05rem;
}

.stack {
  display: grid;
  gap: 1rem;
}

.layout-two {
  display: grid;
  grid-template-columns: minmax(300px, 430px) 1fr;
  gap: 1.15rem;
  align-items: start;
}

.model-picker {
  display: flex;
  align-items: end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* ---- Tabs ------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.15rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.95rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text);
  text-decoration: none;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-pill);
  background: var(--surface-inset);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.tab.active .tab-count {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---- Ort-Autocomplete -------------------------------------------------- */
.ort-picker label {
  position: relative;
}

.ort-vorschlaege {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
  margin-top: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-height: 260px;
  overflow-y: auto;
}

.ort-vorschlag {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0.55rem 0.7rem;
  font-weight: 500;
  color: var(--text);
}

.ort-vorschlag:hover {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: none;
}

.url-preview {
  font-size: 0.78rem;
  word-break: break-all;
  padding: 0.5rem 0.6rem;
  background: var(--surface-inset);
  border-radius: var(--radius-sm);
  margin: 0;
}

/* ---- Anzeigen-Liste --------------------------------------------------- */
.ad-list {
  display: grid;
  gap: 1rem;
}

.ad-card {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.ad-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.ad-card.gone {
  opacity: 0.55;
  filter: grayscale(0.3);
}

.thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  background: var(--surface-inset);
  color: var(--text-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 0.85rem;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ad-head {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 0.4rem;
}

.ad-head h2 {
  margin-bottom: 0;
  line-height: 1.3;
}

.ad-main > .actions {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.muted,
.meta {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.meta {
  margin: 0.15rem 0 0.4rem;
}

.specs {
  font-weight: 600;
  color: var(--text);
}

/* ---- Badges: Score, Pill, Deal --------------------------------------- */
.score,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.4rem;
  border-radius: var(--radius-pill);
  padding: 0.3rem 0.65rem;
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
}

.pill {
  min-width: 0;
  background: var(--surface-inset);
  color: var(--text-muted);
}

.score-9,
.score-10 {
  background: var(--good-soft);
  color: var(--good);
}

.score-7,
.score-8 {
  background: var(--info-soft);
  color: var(--info);
}

.score-5,
.score-6 {
  background: var(--warn-soft);
  color: var(--warn);
}

.score-0,
.score-1,
.score-2,
.score-3,
.score-4 {
  background: var(--bad-soft);
  color: var(--bad);
}

.score-none {
  background: var(--surface-inset);
  color: var(--text-soft);
}

.deal {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--deal-bg);
  border: 1px solid var(--deal-border);
  color: var(--deal);
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

.deal::before {
  content: "🔥";
  font-size: 0.85em;
}

/* ---- Zustände --------------------------------------------------------- */
.empty {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}

.banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  color: var(--warn);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.banner::before {
  content: "⚠";
}

.error {
  color: var(--bad);
}

.mini-result {
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
  margin-top: 0.85rem;
}

.test-results {
  margin-top: 0.5rem;
}

/* ---- Suchen-Uebersicht ------------------------------------------------ */
.add-button {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
}

.add-button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-contrast);
}

.plus {
  font-size: 1.15rem;
  line-height: 1;
  margin-right: 0.1rem;
}

.search-list {
  display: grid;
  gap: 0.85rem;
}

.search-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.15rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-row:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.search-row.paused {
  opacity: 0.62;
}

.search-main {
  flex: 1 1 320px;
  min-width: 0;
}

.search-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.search-head h2 {
  margin: 0;
}

.search-term {
  margin: 0.15rem 0 0.55rem;
}

.pill.on {
  background: var(--good-soft);
  color: var(--good);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--surface-inset);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.search-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
}

.hint {
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Nur direkt unter einem Eingabefeld ruecken Hinweise dichter heran. */
label + .hint {
  margin-top: -0.4rem;
}

/* ---- Live-Status ------------------------------------------------------ */
.live-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--good);
  margin-left: 0.15rem;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.live-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.6rem;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-pill);
  background: var(--surface-inset);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.8rem;
}

.live-badge.busy {
  background: var(--good-soft);
  color: var(--good);
}

.live-badge.busy::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: var(--radius-pill);
  background: currentColor;
  animation: pulse 1.4s ease-in-out infinite;
}

.live-phase {
  margin-bottom: 0.2rem;
  font-size: 1.15rem;
}

.progress {
  height: 1.15rem;
  background: var(--surface-inset);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: 0.8rem;
}

.progress-bar {
  height: 100%;
  min-width: 2.5rem;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #22d3ee);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  transition: width 0.3s ease;
}

.live-stream {
  margin: 0.85rem 0 0;
  padding: 0.7rem 0.8rem;
  background: var(--surface-inset);
  border-radius: var(--radius-sm);
  max-height: 190px;
  overflow-y: auto;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-muted);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  font-size: 0.9rem;
}

.log li {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}

.log li:last-child {
  border-bottom: 0;
}

.log-time {
  color: var(--text-soft);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.8rem;
  margin-right: 0.5rem;
}

/* ---- Statistik -------------------------------------------------------- */
.chart {
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.8rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.legend i {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: var(--radius-pill);
}

/* ---- Responsive ------------------------------------------------------- */
@media (max-width: 820px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  nav {
    justify-content: center;
  }

  /* Gestapelte Kopfzeile: die Konto-Zeile nach rechts, sonst haengt sie
     unter der Navigation in der Luft. */
  .konto {
    justify-content: flex-end;
  }

  .layout-two,
  .ad-card {
    grid-template-columns: 1fr;
  }

  .ad-head {
    flex-direction: column;
  }

  .thumb {
    max-height: 240px;
  }
}

/* ---- Anbieter-Auswahl (Ollama / OpenRouter) --------------------------- */
.backend-choice {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.7rem;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 400;
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.radio-card:hover {
  border-color: var(--accent);
}

.radio-card.gewaehlt {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--ring);
}

.radio-card input {
  width: auto;
  margin-top: 0.2rem;
  accent-color: var(--accent);
}

.radio-card span {
  display: grid;
  gap: 0.25rem;
}

.radio-card strong {
  font-size: 0.95rem;
}

.radio-card small {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.provider-panel {
  display: grid;
  gap: 0.85rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

/* ---- Betriebsuebersicht im Ruhezustand -------------------------------- */
.betrieb {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.7rem;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.betrieb {
  margin-bottom: 0.9rem;
}

.betrieb div {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.betrieb span {
  font-size: 0.78rem;
}

.betrieb strong {
  font-size: 0.92rem;
  word-break: break-word;
}

.log-fehler {
  color: var(--bad);
}

/* ---- Countdown bis zum naechsten Lauf --------------------------------- */
.countdown-liste {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.countdown-liste .countdown {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.countdown-wert {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 700;
}

.countdown-takt {
  font-size: 0.8rem;
}

.chip.countdown {
  gap: 0.3rem;
}

.chip .countdown-wert {
  font-size: 0.78rem;
}

/* ---- Statistik: Kennzahlen und Balken --------------------------------- */
.kennzahlen {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}

.kennzahl {
  display: grid;
  gap: 0.2rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.kennzahl span:last-child {
  font-size: 0.82rem;
  line-height: 1.35;
}

.kennzahl-wert {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kennzahl.gut .kennzahl-wert {
  color: var(--good);
}

.kennzahl.deal-farbe .kennzahl-wert {
  color: var(--deal);
}

/* Balkendiagramme ohne SVG: passen sich damit automatisch dem Theme an. */
.balken-reihe {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  height: 190px;
  margin-top: 0.9rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
}

.balken {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 0.25rem;
  flex: 1 1 0;
  min-width: 30px;
  height: 100%;
}

.balken-saeule {
  width: 100%;
  min-height: 3px;
  border-radius: 6px 6px 0 0;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: height 0.2s ease;
}

.balken.ist-deal .balken-saeule {
  background: color-mix(in srgb, var(--good) 30%, transparent);
  border-color: var(--good);
}

.balken-anteil {
  width: 100%;
  border-radius: 0 0 5px 5px;
  background: color-mix(in srgb, var(--good) 55%, transparent);
}

.balken-zahl {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-height: 1em;
}

.balken-label {
  font-size: 0.72rem;
  color: var(--text-soft);
  white-space: nowrap;
}

.legende-punkt {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 3px;
  margin-right: 0.35rem;
  vertical-align: -1px;
}

.legende-punkt.deal {
  background: color-mix(in srgb, var(--good) 55%, transparent);
}

.deal-wert {
  color: var(--deal);
  font-variant-numeric: tabular-nums;
}

td .pill {
  margin-left: 0.4rem;
}

td .muted {
  display: block;
  font-size: 0.78rem;
}

/* ---- NEU-Kennzeichen auf noch nicht angesehenen Anzeigen -------------- */
.neu-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  margin-right: 0.35rem;
  border-radius: 5px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  vertical-align: 0.15em;
}

/* Farbige Kante links: neue Treffer sind so auch beim Scrollen sofort zu erkennen. */
.ad-card.ist-neu {
  border-left: 3px solid var(--accent);
}

.ad-card.ist-neu.gone {
  border-left-color: var(--border-strong);
}

.toolbar .alle-gesehen {
  margin-top: 0.7rem;
}

/* ---- Hinweis auf frische Scan-Ergebnisse ------------------------------ */
.neu-hinweis {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding: 0.7rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}

.neu-hinweis button {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

/* =========================================================================
   Anmeldung und Konten
   ========================================================================= */
.auth-seite {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-karte {
  width: min(26rem, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 18px);
  box-shadow: var(--shadow-md, 0 12px 32px rgba(16, 24, 40, 0.1));
  padding: clamp(1.5rem, 4vw, 2.25rem);
  margin: 0;
}

.auth-karte h1 {
  margin: 0.25rem 0 1.25rem;
  font-size: 1.45rem;
}

.auth-karte .actions {
  margin-top: 0.5rem;
}

.auth-karte .actions button {
  width: 100%;
  justify-content: center;
}

.auth-marke {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-muted);
}

.auth-marke::before {
  content: "";
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #22d3ee);
}

/* Konto-Anzeige in der Kopfzeile */
.konto {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.konto-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.schlicht {
  background: none;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  box-shadow: none;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

button.schlicht:hover {
  background: var(--surface-inset);
  color: var(--text);
}

.banner.ok {
  background: var(--good-soft);
  border-color: color-mix(in srgb, var(--good) 35%, transparent);
  color: var(--good);
}

.banner.ok::before {
  content: "\2713";
}

.konto-tabelle {
  width: 100%;
  border-collapse: collapse;
}

.konto-tabelle th {
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  padding-bottom: 0.4rem;
}

.konto-tabelle td {
  padding: 0.5rem 0.75rem 0.5rem 0;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.konto-tabelle td:last-child {
  text-align: right;
  padding-right: 0;
}

.konto-tabelle button {
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}

/* =========================================================================
   Markenzeichen, Kippschalter, Bewegung
   ========================================================================= */

/* Lupe mit fallendem Pfeil - liegt als Bild ueber dem Farbverlauf. */
.brand::before,
.auth-marke::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23fff' stroke-linecap='round'%3E%3Ccircle cx='28' cy='27' r='13' stroke-width='6'/%3E%3Cpath d='M38 37.5L49.5 49' stroke-width='7'/%3E%3C/g%3E%3C/svg%3E"), linear-gradient(135deg, var(--accent), #22d3ee);
  background-size: 105% 105%, cover;
  background-position: center, center;
  background-repeat: no-repeat;
  transition: transform 0.25s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.brand:hover::before {
  transform: rotate(-8deg) scale(1.08);
}

/* ---- Kippschalter fuer aktiv/pausiert ---- */
.schalter {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: none;
  border: none;
  box-shadow: none;
  padding: 0.2rem 0.1rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.schalter:hover {
  background: none;
  box-shadow: none;
  transform: none;
  color: var(--text);
}

.schalter-bahn {
  position: relative;
  flex: none;
  width: 2.6rem;
  height: 1.5rem;
  border-radius: var(--radius-pill);
  background: var(--surface-inset);
  border: 1px solid var(--border-strong);
  transition: background 0.22s ease, border-color 0.22s ease;
}

.schalter-knopf {
  position: absolute;
  top: 50%;
  left: 0.18rem;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  /* Leicht ueberschwingend - der Schalter soll sich schnappen, nicht kriechen. */
  transition: transform 0.26s cubic-bezier(0.34, 1.5, 0.64, 1);
  transform: translate(0, -50%);
}

.schalter.an .schalter-bahn {
  background: var(--good);
  border-color: var(--good);
}

.schalter.an .schalter-knopf {
  transform: translate(1.1rem, -50%);
}

.schalter.an .schalter-text {
  color: var(--good);
}

.schalter:focus-visible .schalter-bahn {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Bewegung ---- */
@keyframes auftauchen {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@keyframes hochploppen {
  0%   { opacity: 0; transform: scale(0.7); }
  60%  { transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes einschweben {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

/* Karten laufen leicht versetzt ein - das macht lange Listen ruhiger,
   als wenn alles gleichzeitig aufblitzt. */
.ad-list > .ad-card,
.search-list > .search-row,
.kennzahlen > .kennzahl,
main > .panel,
.layout-two > .panel {
  animation: auftauchen 0.36s ease both;
}

.ad-list > .ad-card:nth-child(1),
.search-list > .search-row:nth-child(1),
.kennzahlen > .kennzahl:nth-child(1) { animation-delay: 0.02s; }
.ad-list > .ad-card:nth-child(2),
.search-list > .search-row:nth-child(2),
.kennzahlen > .kennzahl:nth-child(2) { animation-delay: 0.06s; }
.ad-list > .ad-card:nth-child(3),
.search-list > .search-row:nth-child(3),
.kennzahlen > .kennzahl:nth-child(3) { animation-delay: 0.10s; }
.ad-list > .ad-card:nth-child(4),
.search-list > .search-row:nth-child(4),
.kennzahlen > .kennzahl:nth-child(4) { animation-delay: 0.14s; }
.ad-list > .ad-card:nth-child(5),
.search-list > .search-row:nth-child(5),
.kennzahlen > .kennzahl:nth-child(5) { animation-delay: 0.18s; }
.ad-list > .ad-card:nth-child(n + 6),
.search-list > .search-row:nth-child(n + 6),
.kennzahlen > .kennzahl:nth-child(n + 6) { animation-delay: 0.22s; }

.neu-badge {
  animation: hochploppen 0.4s cubic-bezier(0.34, 1.5, 0.64, 1) both;
}

.banner,
.neu-hinweis {
  animation: einschweben 0.3s ease both;
}

.auth-karte {
  animation: auftauchen 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.kennzahl {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kennzahl:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.search-row {
  transition: border-color 0.15s ease, box-shadow 0.15s ease,
              transform 0.15s ease, opacity 0.2s ease;
}

.search-row:hover {
  transform: translateY(-2px);
}

.chip,
.pill {
  transition: background 0.15s ease, color 0.15s ease;
}

/* Wer Bewegung abgestellt hat, bekommt die Seite still - Zustaende bleiben
   erhalten, nur der Weg dahin faellt weg. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    animation-delay: 0s !important;
    transition-duration: 0.001s !important;
  }
}

/* =========================================================================
   Tabellen auf schmalen Displays
   Statt seitwaerts zu scrollen wird jede Zeile zu einer eigenen Karte. Die
   Spaltenueberschrift steht dann per data-label vor dem Wert.
   ========================================================================= */
@media (max-width: 680px) {
  .tabelle-karten thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  /* Auch Tabelle und Koerper muessen aus dem Tabellenlayout raus - sonst
     behaelt der Container seine alte Mindestbreite und die Seite scrollt
     weiterhin seitwaerts. */
  .tabelle-karten,
  .tabelle-karten tbody {
    display: block;
    width: 100%;
  }

  .tabelle-karten tbody tr {
    display: block;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.6rem;
  }

  .tabelle-karten tbody tr:hover td {
    background: none;
  }

  .tabelle-karten td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.28rem 0;
    border: 0;
    text-align: right;
    /* Lange Werte umbrechen lassen, statt die Karte breiter zu druecken. */
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .tabelle-karten td::before {
    content: attr(data-label);
    flex: none;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-soft);
  }

  /* Die erste Spalte traegt die Karte - sie steht als Ueberschrift oben. */
  .tabelle-karten td:first-child {
    display: block;
    text-align: left;
    font-weight: 700;
    padding-bottom: 0.45rem;
    margin-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
  }

  .tabelle-karten td:first-child::before {
    display: none;
  }

  /* Leere Zellen - etwa die Fehlerspalte im Normalfall - fallen ganz weg. */
  .tabelle-karten td:empty {
    display: none;
  }

  .tabelle-karten td:empty::before {
    content: none;
  }

  /* Die Löschen-Schaltflaeche der Konten-Liste braucht kein Etikett. */
  .konto-tabelle td:last-child {
    justify-content: flex-end;
    padding-top: 0.5rem;
  }
}

/* Hinweis auf eine wacklige Preisquelle. Bewusst zurueckhaltend: die Anzeige
   selbst ist deshalb nicht schlechter, nur die Zahl daneben weniger belastbar. */
.unsicher {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 5px;
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: help;
}
