/* ── Reset & Base ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0d0f14;
  --bg2: #141720;
  --bg3: #1c2030;
  --border: #252a3a;
  --text: #e8eaf0;
  --text2: #8b92a8;
  --text3: #5a6070;
  --accent: #4f8ef7;
  --accent2: #6c63ff;
  --green: #00d97e;
  --red: #ff4757;
  --yellow: #ffd740;
  --orange: #ff8c42;

  --grade-aplus: #00c853;
  --grade-a: #69f0ae;
  --grade-b: #ffd740;
  --grade-c: #ff9100;
  --grade-d: #ff3d00;
  --grade-f: #b71c1c;

  --radius: 12px;
  --radius-sm: 8px;
  font-family: 'Inter', system-ui, sans-serif;
}
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Header ─────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(13,15,20,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.header-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; gap: 24px;
  height: 64px;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon { font-size: 28px; }
.logo-title { font-size: 16px; font-weight: 700; color: var(--text); }
.logo-sub { font-size: 11px; color: var(--text3); margin-top: 1px; }

.header-stats {
  display: flex; gap: 16px; flex: 1;
  margin-left: 32px;
}
.stat-chip {
  display: flex; flex-direction: column; align-items: center;
  background: var(--bg3); border: 1px solid var(--border);
  padding: 6px 14px; border-radius: var(--radius-sm);
  min-width: 90px;
}
.stat-num { font-size: 15px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 10px; color: var(--text3); margin-top: 1px; white-space: nowrap; }

.header-actions {
  display: flex; align-items: center; gap: 12px; margin-left: auto;
}
.last-run-text { font-size: 11px; color: var(--text3); }

/* ── Buttons ─────────────────────────────────────── */
.btn-primary {
  background: var(--accent); color: #fff;
  border: none; padding: 10px 20px;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: opacity .15s;
  text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary.btn-loading { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }

.btn-outline {
  background: transparent; color: var(--accent);
  border: 1px solid var(--accent); padding: 8px 16px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background .15s;
  text-decoration: none;
}
.btn-outline:hover { background: rgba(79,142,247,0.1); }
.btn-outline.starred { color: var(--yellow); border-color: var(--yellow); }

.btn-ghost {
  background: transparent; color: var(--text2);
  border: 1px solid var(--border); padding: 8px 16px;
  border-radius: var(--radius-sm); font-size: 13px;
  cursor: pointer; transition: background .15s; text-decoration: none;
}
.btn-ghost:hover { background: var(--bg3); }

.btn-icon {
  background: transparent; border: 1px solid var(--border);
  padding: 6px 10px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 14px; transition: background .15s, border-color .15s;
}
.btn-icon:hover { background: var(--bg3); border-color: var(--text3); }
.btn-icon.starred { border-color: var(--yellow); }

.btn-large { padding: 12px 24px; font-size: 15px; }

.btn-telegram {
  background: rgba(0,136,204,.15); color: #29b6f6;
  border: 1px solid rgba(0,136,204,.35); padding: 10px 16px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .2s;
}
.btn-telegram:hover { background: rgba(0,136,204,.25); }
.btn-telegram:disabled { opacity: .5; cursor: not-allowed; }
.btn-auto {
  background: var(--bg3); color: var(--text2);
  border: 1px solid var(--border); padding: 10px 16px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .2s;
}
.btn-auto:hover { border-color: var(--text3); }
.btn-auto.auto-on {
  background: rgba(0,217,126,.1); color: var(--green);
  border-color: rgba(0,217,126,.4);
  animation: pulse-border 2s infinite;
}
@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,217,126,.3); }
  50%       { box-shadow: 0 0 0 4px rgba(0,217,126,.0); }
}

/* ── Progress bar ────────────────────────────────── */
.progress-bar {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 16px 24px;
}
.progress-inner { max-width: 1400px; margin: 0 auto; }
.progress-title { font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 8px; }
.progress-log {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-family: 'Courier New', monospace; font-size: 12px;
  color: var(--text2); max-height: 200px; overflow-y: auto;
  line-height: 1.7;
}

/* Spinner */
.spinner {
  width: 14px; height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Filters ─────────────────────────────────────── */
.filters-bar {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.filters-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 10px; color: var(--text3); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.filter-group select {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 12px; font-size: 13px; cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%238b92a8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.results-count { font-size: 13px; color: var(--text3); white-space: nowrap; }

/* ── Empty state ─────────────────────────────────── */
.empty-state {
  text-align: center; padding: 80px 24px;
}
.empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.empty-sub { color: var(--text2); font-size: 14px; }

/* ── Listing Grid ────────────────────────────────── */
.main { max-width: 1400px; margin: 0 auto; padding: 24px; }

.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.listing-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: transform .15s, border-color .15s;
  position: relative;
}
.listing-card:hover { transform: translateY(-2px); border-color: var(--text3); }
.listing-card.card-starred { border-color: var(--yellow) !important; }

/* Grade badge */
.card-grade {
  position: absolute; top: 12px; left: 12px; z-index: 10;
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.grade-Aplus { background: var(--grade-aplus); color: #000; }
.grade-A     { background: var(--grade-a);    color: #000; }
.grade-B     { background: var(--grade-b);    color: #000; }
.grade-C     { background: var(--grade-c);    color: #000; }
.grade-D     { background: var(--grade-d);    color: #fff; }
.grade-F     { background: var(--grade-f);    color: #fff; }

.card-image-link { display: block; }
.card-img {
  width: 100%; height: 180px; object-fit: cover;
  display: block; background: var(--bg3);
}
.card-img-placeholder {
  width: 100%; height: 180px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3); font-size: 48px;
}

.card-body { padding: 14px 16px; }

.card-header-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.card-age { font-size: 11px; color: var(--text3); }

.card-title {
  display: block; font-size: 15px; font-weight: 600;
  color: var(--text); text-decoration: none; margin-bottom: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-title:hover { color: var(--accent); }

.card-meta {
  display: flex; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--text2); margin-bottom: 10px;
}
.card-meta span { background: var(--bg3); padding: 2px 7px; border-radius: 4px; }

/* Source badges */
.source-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  padding: 2px 8px; border-radius: 4px; letter-spacing: .4px;
}
.source-kleinanzeigen { background: #ff6600; color: #fff; }
.source-autoscout24   { background: #0066cc; color: #fff; }
.source-mobile_de     { background: #e63946; color: #fff; }
.source-mobile\ de    { background: #e63946; color: #fff; }

/* Signals */
.signals-row {
  display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px;
}
.signal-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 500;
}
.severity-critical { background: rgba(183,28,28,.25); color: #ff5252; border: 1px solid rgba(183,28,28,.4); }
.severity-high     { background: rgba(255,61,0,.2);   color: #ff6e40; border: 1px solid rgba(255,61,0,.35); }
.severity-medium   { background: rgba(255,145,0,.2);  color: #ffab40; border: 1px solid rgba(255,145,0,.35); }
.severity-low      { background: rgba(255,215,64,.15);color: var(--yellow); border: 1px solid rgba(255,215,64,.3); }
.severity-positive { background: rgba(0,217,126,.15); color: var(--green); border: 1px solid rgba(0,217,126,.3); }

/* Financials */
.financials { background: var(--bg3); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 10px; }
.fin-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; padding: 3px 0;
}
.fin-label { color: var(--text2); }
.fin-value { font-weight: 600; }
.fin-neg { color: var(--red); }
.fin-profit { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 6px; }
.profit-pos .profit-num { color: var(--green); font-size: 14px; }
.profit-neg .profit-num { color: var(--red); font-size: 14px; }

/* Score bar */
.score-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.score-bar-wrap {
  flex: 1; height: 6px; background: var(--bg3);
  border-radius: 3px; overflow: hidden;
}
.score-bar {
  height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 3px; transition: width .3s;
}
.score-bar-wrap.big { height: 10px; border-radius: 5px; }
.score-num { font-size: 12px; color: var(--text2); white-space: nowrap; }

/* Card actions */
.card-actions {
  display: flex; align-items: center; gap: 8px;
}
.card-actions .btn-outline { flex: 1; text-align: center; padding: 7px; font-size: 12px; }

/* ── Pagination ──────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 16px; margin-top: 32px; padding-bottom: 24px;
}
.page-btn {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; padding: 8px 20px;
  border-radius: var(--radius-sm); font-size: 14px;
  transition: background .15s;
}
.page-btn:hover { background: var(--bg2); }
.page-info { color: var(--text2); font-size: 13px; }

/* ── Detail page ─────────────────────────────────── */
.detail-main { max-width: 1200px; margin: 0 auto; padding: 24px; }

.detail-grid {
  display: grid; grid-template-columns: 1fr 420px; gap: 24px;
  margin-bottom: 40px;
}
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.main-image {
  width: 100%; height: 360px; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--border);
}
.no-image-big {
  width: 100%; height: 360px; background: var(--bg3);
  border-radius: var(--radius); display: flex; align-items: center;
  justify-content: center; font-size: 80px;
}
.thumb-row {
  display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap;
}
.thumb {
  width: 80px; height: 60px; object-fit: cover;
  border-radius: var(--radius-sm); cursor: pointer;
  border: 2px solid var(--border); transition: border-color .15s;
}
.thumb:hover { border-color: var(--accent); }

.detail-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
}
.detail-card-title {
  font-size: 13px; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: 14px;
}

.specs-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px;
}
.spec-item { display: flex; flex-direction: column; gap: 2px; }
.spec-label { font-size: 11px; color: var(--text3); }
.spec-value { font-size: 14px; font-weight: 500; }

.description-text {
  font-size: 13px; color: var(--text2); line-height: 1.7;
  white-space: pre-wrap;
}

/* Deal header */
.deal-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.deal-title {
  font-size: 18px; font-weight: 700; line-height: 1.3;
}
.deal-grade-big {
  min-width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
}

.score-card { }
.score-label-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; font-size: 13px; color: var(--text2);
}
.score-big { font-size: 20px; font-weight: 800; color: var(--accent); }

/* Finance breakdown */
.finance-breakdown { }
.fb-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.fb-row:last-child { border-bottom: none; }
.fb-val { font-weight: 600; }
.fb-val.neg { color: var(--orange); }
.fb-divider { height: 1px; background: var(--border); margin: 8px 0; }
.total-invest { font-weight: 600; }
.profit-row { padding: 10px 0; }
.profit-green .fb-val.profit-big { color: var(--green); font-size: 20px; }
.profit-red   .fb-val.profit-big { color: var(--red);   font-size: 20px; }
.roi-pos { color: var(--green); }
.roi-neg { color: var(--red); }

/* Signals detail */
.signals-detail { display: flex; flex-direction: column; gap: 8px; }
.signal-detail-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--bg3);
}
.sig-left { display: flex; align-items: center; gap: 8px; }
.signal-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.sev-critical .signal-dot, .sev-critical { color: #ff5252; }
.signal-dot.sev-critical { background: #ff5252; }
.signal-dot.sev-high     { background: #ff6e40; }
.signal-dot.sev-medium   { background: #ffab40; }
.signal-dot.sev-low      { background: var(--yellow); }
.signal-dot.sev-positive { background: var(--green); }
.sig-label { font-size: 13px; font-weight: 500; }
.sig-badge { font-size: 10px; padding: 1px 6px; border-radius: 3px; color: var(--text3); }
.sig-cost { font-size: 13px; font-weight: 600; color: var(--orange); }
.sig-cost.pos { color: var(--green); }

.repair-total {
  margin-top: 12px; padding: 10px 12px;
  background: rgba(255,145,0,.1); border: 1px solid rgba(255,145,0,.3);
  border-radius: var(--radius-sm); font-size: 13px;
}
.repair-note { font-size: 11px; color: var(--text3); margin-top: 4px; }

.detail-actions {
  display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px;
}
.scraped-info { font-size: 11px; color: var(--text3); text-align: center; }

/* Similar */
.similar-section { margin-top: 8px; }
.similar-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.similar-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.similar-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  text-decoration: none; color: var(--text);
  transition: border-color .15s, transform .15s;
  position: relative;
}
.similar-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.sim-grade {
  position: absolute; top: 10px; right: 10px;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
}
.sim-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; padding-right: 30px; }
.sim-meta { font-size: 12px; color: var(--text2); }

/* ── Price drop badge ────────────────────────────── */
.price-drop-badge {
  position: absolute; top: 12px; right: 12px; z-index: 10;
  background: rgba(0,217,126,.15); color: var(--green);
  border: 1px solid rgba(0,217,126,.35);
  font-size: 11px; font-weight: 700; padding: 3px 8px;
  border-radius: var(--radius-sm);
}

/* ── Age indicators ──────────────────────────────── */
.age-old { color: var(--red); }
.age-mid { color: var(--orange); }

/* ── Filter search input ─────────────────────────── */
.search-group { flex: 1; min-width: 200px; }
.filter-input {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 12px; font-size: 13px; width: 100%;
  font-family: inherit;
}
.filter-input:focus { outline: none; border-color: var(--accent); }

/* ── Original price strikethrough ───────────────── */
.orig-price {
  text-decoration: line-through; color: var(--text3);
  font-size: 11px; margin-left: 4px;
}

/* ── Stats page ──────────────────────────────────── */
.stats-title { font-size: 24px; font-weight: 800; margin-bottom: 24px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 20px;
}
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px;
}
.stat-card.wide { grid-column: span 2; }
@media (max-width: 900px) { .stat-card.wide { grid-column: span 1; } }
.stat-card-title {
  font-size: 14px; font-weight: 700; margin-bottom: 16px;
  color: var(--text2);
}
.chart-wrap { position: relative; height: 220px; }
.no-data { color: var(--text3); font-size: 13px; text-align: center; padding: 20px 0; }

/* Sources table */
.sources-table { display: flex; flex-direction: column; gap: 12px; }
.source-row { display: flex; align-items: center; gap: 12px; }
.source-stats { display: flex; gap: 16px; font-size: 13px; color: var(--text2); }
.profit-text { color: var(--green); font-weight: 600; }
.neg-text { color: var(--red); }

/* Signal frequency */
.signal-list { display: flex; flex-direction: column; gap: 8px; }
.signal-freq-row { display: flex; align-items: center; gap: 8px; }
.signal-freq-label { font-size: 12px; min-width: 140px; color: var(--text); }
.signal-freq-bar-wrap { flex: 1; height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.signal-freq-bar { height: 100%; background: var(--accent2); border-radius: 3px; }
.signal-freq-count { font-size: 12px; color: var(--text3); min-width: 30px; text-align: right; }

/* Makes table */
.makes-table { display: flex; flex-direction: column; gap: 2px; }
.makes-header {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr;
  font-size: 11px; color: var(--text3); font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
  padding: 0 8px 8px;
}
.makes-row {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr;
  padding: 8px; border-radius: var(--radius-sm); font-size: 13px;
  transition: background .15s;
}
.makes-row:hover { background: var(--bg3); }
.make-name { font-weight: 600; }

/* ROI list */
.roi-list { display: flex; flex-direction: column; gap: 10px; }
.roi-row { display: flex; align-items: center; gap: 12px; }
.roi-rank {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg3); display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 700;
  color: var(--text3); flex-shrink: 0;
}
.roi-info { flex: 1; }
.roi-make { font-size: 14px; font-weight: 600; display: block; }
.roi-count { font-size: 11px; color: var(--text3); }
.roi-value { font-size: 18px; font-weight: 800; color: var(--green); }

/* Price drops */
.drops-list { display: flex; flex-direction: column; gap: 8px; }
.drop-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg3); border-radius: var(--radius-sm);
  padding: 10px 14px; text-decoration: none; color: var(--text);
  transition: background .15s;
}
.drop-row:hover { background: rgba(79,142,247,.1); }
.drop-title { flex: 1; font-size: 13px; font-weight: 500; }
.drop-meta { font-size: 12px; color: var(--text3); white-space: nowrap; }
.drop-amount { font-size: 16px; font-weight: 800; color: var(--green); white-space: nowrap; }
.drop-grade {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
}

/* ── Tabs bar ────────────────────────────────────── */
.tabs-bar {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.tabs-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
}
.tab-nav { display: flex; gap: 4px; }
.tab-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 12px 18px; font-size: 13px; font-weight: 600;
  color: var(--text2); text-decoration: none; border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn.active.tab-top { color: var(--yellow); border-bottom-color: var(--yellow); }
.tab-btn.active.tab-star { color: var(--yellow); border-bottom-color: var(--yellow); }
.tab-count {
  background: var(--bg3); color: var(--text3);
  font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 10px;
}
.tab-btn.active .tab-count { background: rgba(79,142,247,.15); color: var(--accent); }
.tab-btn.active.tab-top .tab-count,
.tab-btn.active.tab-star .tab-count { background: rgba(255,215,64,.15); color: var(--yellow); }
.tab-btn.active.tab-contacted { color: #a78bfa; border-bottom-color: #a78bfa; }
.tab-btn.active.tab-contacted .tab-count { background: rgba(167,139,250,.15); color: #a78bfa; }

.view-toggle { display: flex; gap: 4px; }
.view-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text3); padding: 6px 10px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 16px; transition: all .15s;
}
.view-btn:hover { color: var(--text); border-color: var(--text3); }
.view-btn.active { background: var(--bg3); color: var(--accent); border-color: var(--accent); }

/* ── Card summary preview ────────────────────────── */
.card-summary {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px;
  margin-bottom: 10px;
}
.summary-line {
  font-size: 11px; color: var(--text2); line-height: 1.6;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Card action improvements ────────────────────── */
.card-detail-btn { flex: 1; text-align: center; padding: 7px; font-size: 12px; }
.card-ext-btn {
  padding: 7px 10px; font-size: 13px; background: transparent;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text2); text-decoration: none;
  transition: background .15s;
}
.card-ext-btn:hover { background: var(--bg3); color: var(--text); }

/* ── List / table view ───────────────────────────── */
.listing-table {
  display: flex; flex-direction: column; gap: 0;
}
.table-header {
  display: grid;
  grid-template-columns: 52px 1fr 80px 85px 90px 55px 90px 100px 100px;
  gap: 8px; padding: 8px 16px;
  font-size: 10px; color: var(--text3); font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
}
.table-row {
  display: grid;
  grid-template-columns: 52px 1fr 80px 85px 90px 55px 90px 100px 100px;
  gap: 8px; padding: 10px 16px; align-items: center;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.table-row:hover { background: var(--bg2); }
.table-row.row-starred { border-left: 3px solid var(--yellow); }

.tbl-grade {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
}
.tbl-title a { color: var(--text); text-decoration: none; font-size: 13px; font-weight: 500; }
.tbl-title a:hover { color: var(--accent); }
.tbl-title small { color: var(--text3); font-size: 11px; margin-left: 6px; }
.tbl-price { font-size: 13px; font-weight: 700; }
.tbl-repair { font-size: 12px; }
.tbl-profit { font-size: 13px; font-weight: 700; }
.tbl-score { font-size: 13px; color: var(--accent); font-weight: 700; }
.tbl-km { font-size: 12px; color: var(--text2); }
.tbl-source { font-size: 10px; }
.tbl-actions { display: flex; gap: 4px; }
.profit-pos-text { color: var(--green); }
.profit-neg-text { color: var(--red); }

/* ── Analysis summary on detail page ─────────────── */
.summary-card { border-left: 3px solid var(--accent2); }
.summary-text { display: flex; flex-direction: column; gap: 6px; }
.summary-line-detail {
  font-size: 13px; color: var(--text2); line-height: 1.5;
  padding: 4px 0; border-bottom: 1px solid var(--border);
}
.summary-line-detail:last-child { border-bottom: none; }

/* ── Analysis cards (Marktwert, KI) ──────────────────────────── */

/* Claude AI analysis */
.ai-bar { border-color: rgba(217,119,87,.35); }
.btn-ai { background: #d97757; }
.ai-card { border-left: 3px solid #d97757; }
.ai-verdict {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 18px; font-weight: 700; padding: 10px 14px;
  border-radius: var(--radius-sm); margin-bottom: 12px;
}
.ai-verdict.ai-kaufen { background: rgba(0,217,126,.12); color: var(--green); }
.ai-verdict.ai-verhandeln { background: rgba(255,215,64,.12); color: var(--yellow); }
.ai-verdict.ai-finger_weg { background: rgba(255,71,87,.12); color: var(--red); }
.ai-confidence { font-size: 12px; font-weight: 500; color: var(--text2); }
.ai-summary { color: var(--text); line-height: 1.55; margin: 0 0 14px; }
.ai-numbers {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px; margin-bottom: 10px;
}
.ai-numbers div {
  background: var(--bg3); border-radius: var(--radius-sm); padding: 8px 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.ai-numbers span { font-size: 11px; color: var(--text2); }
.ai-numbers strong { font-size: 16px; }
.ai-numbers .pos { color: var(--green); }
.ai-numbers .neg { color: var(--red); }
.ai-reasoning { font-size: 13px; color: var(--text2); line-height: 1.5; margin: 0 0 14px; }
.ai-section { margin-bottom: 12px; }
.ai-section-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.ai-section ul { margin: 0; padding-left: 18px; color: var(--text); font-size: 13px; line-height: 1.55; }
.ai-meta { font-size: 11px; color: var(--text3); margin: 12px 0; }
.ai-error { color: var(--red); font-size: 13px; margin: 8px 0; }
.ai-badge {
  display: block; font-size: 12px; font-weight: 600; text-decoration: none;
  padding: 5px 8px; border-radius: var(--radius-sm); margin: 6px 0;
}
.ai-badge.ai-kaufen { background: rgba(0,217,126,.12); color: var(--green); }
.ai-badge.ai-verhandeln { background: rgba(255,215,64,.12); color: var(--yellow); }
.ai-badge.ai-finger_weg { background: rgba(255,71,87,.12); color: var(--red); }
.dr-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.dr-timestamp { font-size: 11px; color: var(--text3); }
.dr-text {
  font-size: 12px; color: var(--text2); line-height: 1.8;
  white-space: pre-wrap; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 12px;
  font-family: 'Courier New', monospace;
}
.dr-empty {
  font-size: 13px; color: var(--text3); margin-bottom: 12px;
  padding: 12px 0;
}
.dr-btn { width: 100%; justify-content: center; }

/* ── Bulk action bars (Gemerkt) ──────────────────────── */
.bulk-research-bar {
  background: linear-gradient(135deg, rgba(168,85,247,.08), rgba(79,142,247,.08));
  border-bottom: 1px solid rgba(168,85,247,.25);
  padding: 14px 24px;
}
.bulk-research-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.bulk-research-info { display: flex; align-items: center; gap: 14px; }
.bulk-icon { font-size: 28px; }
.bulk-title { font-size: 14px; font-weight: 700; color: var(--text); }
.bulk-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }
.btn-bulk {
  background: linear-gradient(135deg, #a855f7, #6c63ff);
  white-space: nowrap; flex-shrink: 0;
}
.btn-bulk:hover { opacity: 0.88; }

.bulk-progress-bar-outer {
  max-width: 1400px; margin: 12px auto 0;
  height: 6px; background: rgba(168,85,247,.15);
  border-radius: 3px; overflow: hidden;
}
.bulk-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #a855f7, #6c63ff);
  border-radius: 3px; transition: width .4s ease;
}
.bulk-progress-label {
  max-width: 1400px; margin: 6px auto 0;
  font-size: 12px; color: #a78bfa; font-weight: 600;
}
.bulk-log {
  max-width: 1400px; margin: 8px auto 0;
  background: var(--bg); border: 1px solid rgba(168,85,247,.2);
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-family: 'Courier New', monospace; font-size: 11px;
  color: var(--text2); max-height: 180px; overflow-y: auto;
  line-height: 1.8;
}

/* ── Contacted badge (card overlay) ─────────────── */
.contacted-badge {
  position: absolute; top: 12px; right: 12px; z-index: 10;
  background: rgba(108,99,255,.2); color: #a78bfa;
  border: 1px solid rgba(108,99,255,.4);
  font-size: 11px; font-weight: 700; padding: 3px 9px;
  border-radius: var(--radius-sm);
}
.listing-card.card-contacted { border-color: rgba(108,99,255,.4) !important; }

/* ── Contact button states ───────────────────────── */
.btn-contact.contacted {
  border-color: rgba(108,99,255,.5);
  color: #a78bfa;
}

/* ── Seller message card ─────────────────────────── */
.seller-msg-card { border-left: 3px solid var(--green); }
.seller-msg-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.btn-copy {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); padding: 5px 14px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.btn-copy:hover { border-color: var(--green); color: var(--green); }
.btn-copy.copied { background: rgba(0,217,126,.1); border-color: var(--green); color: var(--green); }

.seller-msg-text {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text2);
  font-size: 13px; line-height: 1.7; padding: 12px 14px;
  resize: vertical; min-height: 130px; font-family: inherit;
}
.seller-msg-text:focus { outline: none; border-color: var(--accent); }

.seller-msg-actions {
  display: flex; align-items: center; gap: 12px;
  margin-top: 10px; flex-wrap: wrap;
}
.btn-contact-toggle {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .15s; flex: 1;
}
.btn-contact-toggle:hover { border-color: #a78bfa; color: #a78bfa; }
.btn-contact-toggle.contacted {
  background: rgba(108,99,255,.1);
  border-color: rgba(108,99,255,.5); color: #a78bfa;
}
.contacted-at-text { font-size: 11px; color: var(--text3); white-space: nowrap; }

/* ── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  .header-stats { display: none; }
  .listing-grid { grid-template-columns: 1fr; }
  .filters-form { overflow-x: auto; flex-wrap: nowrap; }
}
