/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e1e4e8;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --success: #16a34a;
  --danger: #dc2626;
  --star: #d97706;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,.08), 0 2px 12px rgba(0,0,0,.04);
}

/* ── Theme: dark ──────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #161b27;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e2e8f0;
  --text-muted: #64748b;
  --primary: #818cf8;
  --primary-hover: #a78bfa;
  --success: #34d399;
  --danger: #f87171;
  --star: #fbbf24;
  --shadow: 0 1px 4px rgba(0,0,0,.4), 0 2px 12px rgba(0,0,0,.3);
}

[data-theme="dark"] .nav__link--active { background: rgba(99, 102, 241, 0.15); }
[data-theme="dark"] .chip { background: rgba(99, 102, 241, 0.15); }
[data-theme="dark"] .card__image--empty {
  background: linear-gradient(135deg, #1e2433 0%, #252e42 100%);
}
[data-theme="dark"] .btn--success { background: rgba(52, 211, 153, 0.12); }
[data-theme="dark"] .btn--danger  { background: rgba(248, 113, 113, 0.12); }
[data-theme="dark"] .btn--danger-outline { border-color: rgba(248, 113, 113, 0.4); }
[data-theme="dark"] .btn--star       { background: rgba(251, 191, 36, 0.12); }
[data-theme="dark"] .btn--irrelevant { background: rgba(120, 120, 120, 0.12); }
[data-theme="dark"] .login-error  { background: rgba(248, 113, 113, 0.12); }
[data-theme="dark"] .filter-tab:hover { background: rgba(255, 255, 255, 0.06); }
[data-theme="dark"] .kw-tab { background: var(--surface); }
[data-theme="dark"] .kw-tab:hover { background: rgba(255, 255, 255, 0.06); }
[data-theme="dark"] .stat-item { background: rgba(255, 255, 255, 0.04); }
[data-theme="dark"] .settings-input:focus,
[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .login-field input:focus { background: var(--surface); }

/* ── Theme toggle button ──────────────────────────────────────── */
.theme-toggle { padding: 5px 9px; font-size: 15px; line-height: 1; }
.theme-toggle::before { content: '☽'; }
[data-theme="dark"] .theme-toggle::before { content: '☀'; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}

a { color: inherit; text-decoration: none; }

/* ── Nav ──────────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav__brand {
  font-weight: 700; font-size: 17px; color: var(--primary); white-space: nowrap;
}

.nav__toggle {
  display: none;
  margin-left: auto;
  background: none; border: none; color: var(--text);
  font-size: 22px; line-height: 1; padding: 6px 8px; cursor: pointer;
}

.nav__menu { display: contents; }

.nav__links { display: flex; gap: 4px; flex: 1; }
.nav__user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.nav__username { font-size: 13px; color: var(--text-muted); }

.nav__link {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 6px;
  font-size: 14px; font-weight: 500; color: var(--text-muted);
  transition: background .15s, color .15s;
}
.nav__link:hover { background: var(--bg); color: var(--text); }
.nav__link--active { color: var(--primary); background: #eef2ff; }

/* ── Badge ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; font-size: 11px; font-weight: 700;
  background: var(--danger); color: #fff;
}
.badge--lg { min-width: 24px; height: 24px; font-size: 13px; border-radius: 12px; }
.badge--admin { background: var(--primary); }

/* ── Main layout ──────────────────────────────────────────────── */
.main { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }

.page-header {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 8px; }

/* ── Keyword chips in feed header ─────────────────────────────── */
.keyword-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; background: #eef2ff; color: var(--primary);
}

/* ── Card grid ────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ── Card ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex; flex-direction: column;
  position: relative;
}
.card--form { display: block; padding: 20px; }
.card--table { display: block; }
.card--table .card__section-title { padding: 20px 20px 14px; margin-bottom: 0; }

.card__image {
  width: 100%; aspect-ratio: 4/3;
  object-fit: cover; display: block;
  background: var(--bg);
}
.card__image--empty {
  width: 100%; aspect-ratio: 4/3;
  background: linear-gradient(135deg, #e5e7eb 0%, #f3f4f6 100%);
}

.card__body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }

.card__title {
  font-size: 14px; font-weight: 600; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card__title:hover { color: var(--primary); }

.card__price-row { display: flex; align-items: center; gap: 8px; min-height: 22px; }
.card__meta-row  { display: flex; align-items: center; gap: 6px; min-height: 18px; margin-top: 3px; }
.card__rating-row { display: flex; align-items: center; gap: 6px; min-height: 18px; margin-top: 2px; }

.card__price { font-size: 15px; font-weight: 700; color: var(--text); }
.card__price--none { color: var(--text-muted); font-weight: 400; }
.card__city { font-size: 12px; color: var(--text-muted); }
.card__seller-name { font-size: 12px; color: var(--text-muted); }
.card__seller-name::before { content: "·"; margin-right: 4px; color: var(--border); }
.card__date { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.card__olx-link { font-size: 12px; color: var(--text-muted); text-decoration: none; }
.card__olx-link:hover { color: var(--accent); }
.card__note { font-size: 13px; color: var(--text-muted); font-style: italic; }

.card__rating { font-size: 12px; font-weight: 600; color: #e6a817; }
.card__rating-count { font-size: 12px; color: var(--text-muted); }
.card__deliveries { font-size: 12px; color: var(--text-muted); }
.card__seller-extra { margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.card__seller-member-since { font-size: 11px; color: var(--text-muted); opacity: .85; }

.card__status { font-size: 12px; font-weight: 600; }
.card__status--top { color: var(--star); }
.card__status--interested { color: var(--success); }

.card__actions { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; }
.card__actions > .btn { flex: 1; min-width: 0; justify-content: center; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 7px 12px; border-radius: 6px; font-size: 13px; font-weight: 500;
  border: none; cursor: pointer; transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:hover { opacity: .88; }

.btn--primary   { background: var(--primary); color: #fff; }
.btn--success   { background: #dcfce7; color: var(--success); }
.btn--danger         { background: #fee2e2; color: var(--danger); }
.btn--danger-outline { background: transparent; color: var(--danger); border: 1px solid #fca5a5; }
.btn--star           { background: #fef3c7; color: var(--star); }
.btn--irrelevant     { background: #f3f4f6; color: var(--text-muted); border: 1px solid var(--border); }
.btn--secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn--sm        { padding: 4px 10px; font-size: 12px; }

/* ── Table ────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 10px 20px; font-size: 12px; font-weight: 600;
             color: var(--text-muted); border-bottom: 2px solid var(--border); }
.table td { padding: 12px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.card__section-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.kw-row-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kw-row-actions .settings-inline-form { margin-top: 0; }
.kw-row-actions .settings-input { min-width: 220px; padding: 6px 8px; font-size: 12px; }
.kw-sections { display: flex; flex-direction: column; gap: 20px; }

/* ── Form ─────────────────────────────────────────────────────── */
.form-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.form-group--wide { flex: 1; min-width: 200px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-group input, .note-form input {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; background: var(--bg); color: var(--text);
  transition: border-color .15s;
}
.form-group input:focus, .note-form input:focus {
  outline: none; border-color: var(--primary);
}

/* ── Note form in saved ───────────────────────────────────────── */
.note-form { display: flex; gap: 8px; min-width: 0; }
.note-form input { flex: 1; min-width: 0; }
.note-form .btn { flex-shrink: 0; }
.note-saved { font-size: 12px; color: var(--success); font-weight: 600; }

/* ── Status dot ───────────────────────────────────────────────── */
.status-dot { font-size: 12px; font-weight: 600; }
.status-dot--active { color: var(--success); }
.status-dot--inactive { color: var(--text-muted); }

/* ── Filter tabs ──────────────────────────────────────────────── */
.filter-tabs { display: flex; gap: 4px; margin-left: auto; }
.sort-controls { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.sort-sep { color: var(--border); padding: 0 2px; user-select: none; }
.filter-tab {
  padding: 6px 14px; border-radius: 6px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); transition: background .15s, color .15s;
}
.filter-tab:hover { background: var(--border); }
.filter-tab--active { background: var(--primary); color: #fff; }

/* ════════════════════════════════════════════════════════════════
   SETTINGS PAGE
   ════════════════════════════════════════════════════════════════ */

.settings-grid {
  display: flex; flex-direction: column; gap: 20px;
  max-width: 720px;
}

.settings-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.settings-card__title {
  font-size: 15px; font-weight: 700; margin-bottom: 18px;
}
.settings-card__footer { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

/* Stats */
.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.stat-item {
  background: var(--bg); border-radius: 8px; padding: 14px 12px; text-align: center;
}
.stat-item__value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-item__label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-item--new .stat-item__value       { color: var(--primary); }
.stat-item--seen .stat-item__value      { color: var(--text-muted); }
.stat-item--interested .stat-item__value{ color: var(--success); }
.stat-item--top .stat-item__value       { color: var(--star); }
.stat-item--skipped .stat-item__value   { color: var(--danger); }

/* Storage */
.storage-disk { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.storage-disk__header { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.storage-disk__bar { height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.storage-disk__bar-fill { height: 100%; background: var(--success); border-radius: 4px; transition: width .2s; }
.storage-disk__bar-fill--warn { background: var(--star); }
.storage-disk__bar-fill--danger { background: var(--danger); }
.storage-disk__free { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* Actions */
.settings-actions { display: flex; flex-direction: column; gap: 0; }
.settings-action {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.settings-action:last-child { border-bottom: none; }
.settings-action--danger .settings-action__name { color: var(--danger); }
.settings-action__info { flex: 1; }
.settings-action__name { font-size: 14px; font-weight: 600; }
.settings-action__desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.action-result { font-size: 13px; font-weight: 600; white-space: nowrap; }
.action-result--ok { color: var(--success); }
.action-result--err { color: var(--danger); }
.settings-inline-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.settings-input { flex: 1; min-width: 180px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; background: var(--bg); color: var(--text); }
.settings-card__hint { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.settings-card__hint a { color: var(--primary); text-decoration: underline; }
.settings-card__hint code { background: var(--bg); padding: 1px 4px; border-radius: 3px; font-size: 12px; }

/* Scraper info */
.settings-empty { font-size: 13px; color: var(--text-muted); }

/* ════════════════════════════════════════════════════════════════
   SCRAPER STATS DASHBOARD (feed page)
   ════════════════════════════════════════════════════════════════ */

.scraper-stats {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.scraper-stats__bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.scraper-stats__sep { color: var(--border); user-select: none; }
.scraper-stats__spacer { flex: 1; min-width: 8px; }
.scraper-stats__interval { font-size: 12px; }
.scraper-stats__next { font-size: 12px; }

.scraper-stats__highlight-new   { color: var(--success); font-weight: 600; }
.scraper-stats__highlight-price { color: var(--star);    font-weight: 600; }

.scraper-stats__dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.scraper-stats__dot--ok      { background: var(--success); }
.scraper-stats__dot--running { background: var(--star); animation: scraper-pulse 1s ease-in-out infinite; }
.scraper-stats__dot--idle    { background: var(--border); }

@keyframes scraper-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.scraper-stats__run-btn { margin-left: 4px; }

/* Per-keyword chips */
.scraper-stats__kw-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.scraper-stats__kw-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
}

.scraper-stats__kw-total { color: var(--text-muted); }

/* Log section */
.scraper-stats__log {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.scraper-stats__log summary {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 5px;
}
.scraper-stats__log summary::before { content: '▶'; font-size: 9px; transition: transform .15s; }
.scraper-stats__log[open] summary::before { transform: rotate(90deg); }

.scraper-stats__log-body {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.scraper-stats__log-line {
  padding: 2px 0;
  color: var(--text-muted);
  line-height: 1.6;
}
.scraper-stats__log-line--new  { color: var(--success); }
.scraper-stats__log-line--err  { color: var(--danger); }
.scraper-stats__log-line--done { color: var(--text); font-weight: 600; }

[data-theme="dark"] .scraper-stats__kw-chip { background: rgba(255,255,255,0.05); }

.blocked-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.blocked-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 0; border-bottom: 1px solid var(--border);
}
.blocked-item:last-child { border-bottom: none; }
.blocked-item__name { font-size: 14px; }

.settings-info-list { display: flex; flex-direction: column; gap: 0; }
.settings-info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.settings-info-row:last-child { border-bottom: none; }
.settings-info-row__label { color: var(--text-muted); }
.settings-info-row__value { font-weight: 600; }

/* ── Empty state ──────────────────────────────────────────────── */
.empty-state {
  grid-column: 1 / -1; text-align: center;
  padding: 48px; color: var(--text-muted); font-size: 15px;
}

/* ── Spinner ──────────────────────────────────────────────────── */
.spinner { text-align: center; padding: 16px; color: var(--text-muted); font-size: 13px; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: block; }

/* ── Button extras ────────────────────────────────────────────── */
.btn--lg    { padding: 10px 20px; font-size: 15px; }
.btn--block { width: 100%; justify-content: center; }
.btn--active { box-shadow: inset 0 0 0 2px currentColor; }

/* ── Phone result ─────────────────────────────────────────────── */
.phone-result { font-size: 15px; font-weight: 600; }
.phone-result a { color: var(--primary); text-decoration: underline; }

/* ════════════════════════════════════════════════════════════════
   DETAIL PAGE
   ════════════════════════════════════════════════════════════════ */

/* Top nav (back / next) */
.detail-topnav { display: flex; gap: 8px; margin-bottom: 16px; }

/* ── Thumbnail strip ──────────────────────────────────────────── */
.detail-thumbs {
  display: flex; gap: 8px; overflow-x: auto;
  margin-bottom: 24px; padding-bottom: 4px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.detail-thumbs__item {
  flex-shrink: 0; width: 80px; height: 60px;
  border-radius: 6px; overflow: hidden;
  border: 2px solid transparent; transition: border-color .15s;
  display: block;
}
.detail-thumbs__item:hover { border-color: var(--primary); }
.detail-thumbs__item img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

/* ── Photos stack (bottom) ────────────────────────────────────── */
.detail-photos {
  margin-top: 40px;
  display: flex; flex-direction: column; gap: 12px;
}
.detail-photos__img {
  display: block; width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  scroll-margin-top: 72px;
}

/* ── Title ────────────────────────────────────────────────────── */
.detail-title {
  font-size: 22px; font-weight: 800; line-height: 1.3;
  margin-bottom: 12px;
}

/* ── Three-column layout ──────────────────────────────────────── */
.detail-layout {
  display: grid;
  grid-template-columns: 240px 1fr 260px;
  gap: 28px;
  align-items: start;
}

.detail-left {
  position: sticky; top: 72px;
  display: flex; flex-direction: column; gap: 16px;
  min-width: 0;
}

.detail-main {
  min-width: 0;
}

.detail-right {
  position: sticky; top: 72px;
  display: flex; flex-direction: column; gap: 16px;
  min-width: 0;
}

/* ── Center column content ────────────────────────────────────── */
.detail-section { margin-bottom: 28px; }
.detail-section__title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-muted);
  margin-bottom: 12px;
}
.detail-desc {
  font-size: 14px; line-height: 1.7; color: var(--text);
}
.detail-desc p { margin-bottom: 10px; }
.detail-desc p:last-child { margin-bottom: 0; }

.detail-attrs { display: grid; }
.detail-attrs__row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px;
  gap: 16px;
}
.detail-attrs__row:last-child { border-bottom: none; }
.detail-attrs__row dt { color: var(--text-muted); flex-shrink: 0; }
.detail-attrs__row dd { font-weight: 500; text-align: right; }

.detail-aside__price-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px;
}
.detail-aside__price { font-size: 28px; font-weight: 800; }
.detail-aside__price--none { font-size: 16px; font-weight: 400; color: var(--text-muted); }
.price-history { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.price-history__row { font-size: 11px; color: var(--text-muted); }
.detail-aside__location { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.detail-aside__actions {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
}

.detail-aside__seller {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.detail-aside__seller-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-muted);
}
.detail-aside__seller-name { font-size: 15px; font-weight: 600; }
.detail-aside__seller-sub { font-size: 13px; color: var(--text-muted); }
.detail-aside__phone { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

.seller-profile { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.seller-profile__rating { display: flex; align-items: baseline; gap: 6px; }
.seller-profile__score { font-size: 15px; font-weight: 700; color: var(--accent); }
.seller-profile__count { font-size: 12px; color: var(--text-muted); }
.seller-profile__meta { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-muted); }
.seller-profile__meta span { display: flex; align-items: center; gap: 4px; }
.seller-profile__member-since { font-size: 11px; color: var(--text-muted); opacity: .85; }
.seller-profile__updated { font-size: 11px; color: var(--text-muted); opacity: .7; margin-top: 2px; }
#phone-result { font-size: 15px; font-weight: 600; }

.detail-aside__dates {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.detail-aside__date-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.detail-aside__date-label {
  font-size: 11px; color: var(--text-muted); white-space: nowrap;
}
.detail-aside__date-val {
  font-size: 11px; font-weight: 600; color: var(--text); white-space: nowrap;
}
.date-ago { font-weight: 400; color: var(--text-muted); }

.detail-aside__note {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.detail-aside__note-text { font-size: 13px; color: var(--text-muted); font-style: italic; }

/* ── Keyword tabs ─────────────────────────────────────────────── */
.kw-tabs {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px;
}
.kw-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 14px; border-radius: 20px; font-size: 13px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-muted); transition: background .15s, color .15s, border-color .15s;
}
.kw-tab:hover { background: var(--bg); color: var(--text); }
.kw-tab--active { background: var(--primary); color: #fff; border-color: var(--primary); }
.kw-tab--active .badge { background: rgba(255,255,255,.3); color: #fff; }

/* ── Login page ───────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px 32px;
  box-shadow: var(--shadow);
}
.login-title { font-size: 22px; font-weight: 700; color: var(--primary); margin-bottom: 28px; text-align: center; }
.login-error { font-size: 13px; color: var(--danger); background: #fee2e2; padding: 8px 12px; border-radius: 6px; margin-bottom: 16px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-field { display: flex; flex-direction: column; gap: 6px; }
.login-field label { font-size: 13px; font-weight: 500; }
.login-field input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 15px; background: var(--bg); outline: none;
  transition: border-color .15s;
}
.login-field input:focus { border-color: var(--primary); background: var(--surface); }

/* ── Admin page ───────────────────────────────────────────────── */
.admin-user-form { margin-bottom: 4px; }
.admin-form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin-form-row input[type="text"],
.admin-form-row input[type="password"] {
  flex: 1; min-width: 120px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}
.admin-checkbox { display: flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; }

/* ── Responsive ───────────────────────────────────────────────── */

/* Tablet: collapse right sidebar below center */
@media (max-width: 1100px) {
  .detail-layout {
    grid-template-columns: 220px 1fr;
    grid-template-areas:
      "left main"
      ".    right";
  }
  .detail-left  { grid-area: left; }
  .detail-main  { grid-area: main; }
  .detail-right { grid-area: right; position: static; }
}

/* Mobile: single column */
@media (max-width: 640px) {
  .nav { padding: 0 12px; gap: 12px; height: auto; min-height: 56px; flex-wrap: wrap; }
  .nav__toggle { display: block; }
  .nav__menu {
    display: none;
    flex-direction: column; align-items: stretch; gap: 4px;
    width: 100%; padding: 4px 0 12px;
  }
  .nav__menu.nav__menu--open { display: flex; }
  .nav__links { flex-direction: column; flex: none; width: 100%; }
  .nav__user { margin-left: 0; flex-wrap: wrap; }
  .main { padding: 16px 12px; }
  .card-grid { grid-template-columns: 1fr; }
  .filter-tabs { margin-left: 0; }
  .page-header { flex-direction: column; align-items: flex-start; }

  /* Flatten left/right asides into the main flow so their individual blocks
     can be reordered independently — title/thumbs/description first, then
     the actions block (incl. "Відкрити на OLX"), then everything else. */
  .detail-layout {
    display: flex; flex-direction: column; align-items: stretch; gap: 16px;
    grid-template-columns: none; grid-template-areas: none;
  }
  .detail-left, .detail-right { display: contents; }

  .detail-main            { order: 1; }
  .detail-aside__actions  { order: 2; }
  .detail-aside__price-block { order: 3; }
  .aws                     { order: 4; }
  .detail-aside__reassign { order: 5; }
  .detail-aside__seller   { order: 6; }
  .detail-aside__dates    { order: 7; }
  .detail-aside__note     { order: 8; }

  .detail-title { font-size: 19px; }
  .detail-aside__price { font-size: 22px; }
}

/* Card hover tooltip */
.card-tooltip {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  max-width: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ct-desc {
  margin: 0;
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ct-note {
  font-size: 12px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 4px;
  padding: 6px 8px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
@media (hover: none) { .card-tooltip { display: none !important; } }

/* ════════════════════════════════════════════════════════════════
   ANALYTICS WIDGET  ·  theme-aware
   ════════════════════════════════════════════════════════════════ */

/* ── Full-width container (light default) ─────────────────────── */
.aw {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  color: var(--text);
  position: relative;
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────────── */
.aw__header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px; gap: 12px;
}
.aw__header-left { display: flex; align-items: flex-start; gap: 14px; }
.aw__icon { font-size: 22px; color: var(--primary); line-height: 1.2; flex-shrink: 0; margin-top: 1px; }
.aw__title { font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.aw__kw { color: var(--primary); }
.aw__subtitle { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.aw__currency-badge {
  background: #eef2ff;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 6px; padding: 4px 10px;
  font-size: 11px; font-weight: 700; color: var(--primary);
  letter-spacing: 0.08em; text-transform: uppercase; flex-shrink: 0;
}

/* ── Stats row ────────────────────────────────────────────────── */
.aw__stats {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 8px; margin-bottom: 20px;
}
.aw__stat {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 10px;
  text-align: center; transition: background 0.2s;
}
.aw__stat:hover { background: var(--border); }
.aw__stat--primary {
  background: #eef2ff; border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 0 18px rgba(99, 102, 241, 0.07);
}
.aw__stat-val { font-size: 18px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; line-height: 1.1; }
.aw__stat--primary .aw__stat-val { color: var(--primary); }
.aw__stat-val--green { color: var(--success); }
.aw__stat-val--red   { color: var(--danger); }
.aw__stat-val--muted { color: var(--text-muted); }
.aw__stat-lbl {
  font-size: 10px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.07em; margin-top: 5px; font-weight: 600;
}

/* ── Charts grid ──────────────────────────────────────────────── */
.aw__charts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.aw__chart-block {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
}
.aw__chart-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 12px;
}
.aw__boxplot-container { min-height: 96px; display: flex; align-items: center; }

/* ── Empty state ──────────────────────────────────────────────── */
.aw--empty { display: flex; align-items: center; gap: 16px; padding: 18px 24px; }
.aw__empty-icon { font-size: 24px; color: var(--text-muted); opacity: 0.45; flex-shrink: 0; }
.aw__empty-title { font-size: 14px; font-weight: 600; color: var(--text); }
.aw__empty-desc { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.5; }

/* ── Loading skeleton ─────────────────────────────────────────── */
.aw-loading {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px 24px; margin-bottom: 24px;
  color: var(--text-muted); font-size: 13px;
  animation: aw-pulse 1.5s ease-in-out infinite;
}
@keyframes aw-pulse {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

/* ── Dark theme overrides for .aw ────────────────────────────── */
[data-theme="dark"] .aw {
  background: linear-gradient(135deg, #0d1117 0%, #161b27 60%, #1a1f35 100%);
  border-color: rgba(99, 102, 241, 0.22);
  box-shadow: 0 4px 40px rgba(0,0,0,.5), 0 0 0 1px rgba(99,102,241,.07), inset 0 1px 0 rgba(255,255,255,.04);
  color: #e2e8f0;
}
[data-theme="dark"] .aw::before {
  content: ''; position: absolute; top: -100px; left: -100px;
  width: 340px; height: 340px;
  background: radial-gradient(circle, rgba(99,102,241,.07) 0%, transparent 65%);
  pointer-events: none;
}
[data-theme="dark"] .aw::after {
  content: ''; position: absolute; bottom: -80px; right: -80px;
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(139,92,246,.06) 0%, transparent 65%);
  pointer-events: none;
}
[data-theme="dark"] .aw__icon { color: #6366f1; }
[data-theme="dark"] .aw__title { color: #f1f5f9; }
[data-theme="dark"] .aw__kw { color: #a78bfa; }
[data-theme="dark"] .aw__subtitle { color: #475569; }
[data-theme="dark"] .aw__currency-badge { background: rgba(99,102,241,.14); border-color: rgba(99,102,241,.32); color: #818cf8; }
[data-theme="dark"] .aw__stat { background: rgba(255,255,255,.03); border-color: rgba(255,255,255,.05); }
[data-theme="dark"] .aw__stat:hover { background: rgba(255,255,255,.055); }
[data-theme="dark"] .aw__stat--primary { background: rgba(99,102,241,.1); border-color: rgba(99,102,241,.28); box-shadow: 0 0 18px rgba(99,102,241,.1); }
[data-theme="dark"] .aw__stat-val { color: #f1f5f9; }
[data-theme="dark"] .aw__stat--primary .aw__stat-val { color: #a78bfa; }
[data-theme="dark"] .aw__stat-val--green { color: #34d399; }
[data-theme="dark"] .aw__stat-val--red   { color: #f87171; }
[data-theme="dark"] .aw__stat-val--muted { color: #64748b; }
[data-theme="dark"] .aw__stat-lbl { color: #475569; }
[data-theme="dark"] .aw__chart-block { background: rgba(255,255,255,.025); border-color: rgba(255,255,255,.05); }
[data-theme="dark"] .aw__chart-title { color: #475569; }
[data-theme="dark"] .aw__empty-icon { color: #1e293b; opacity: 1; }
[data-theme="dark"] .aw__empty-title { color: #334155; }
[data-theme="dark"] .aw__empty-desc { color: #253247; }
[data-theme="dark"] .aw-loading { background: linear-gradient(135deg, #0d1117 0%, #161b27 100%); border-color: rgba(99,102,241,.1); color: #334155; }

/* ════════════════════════════════════════════════════════════════
   ANALYTICS SIDEBAR WIDGET  ·  theme-aware
   ════════════════════════════════════════════════════════════════ */

.aws {
  background: var(--surface);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.aws__header { display: flex; align-items: center; justify-content: space-between; }
.aws__title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--primary); }
.aws__count { font-size: 11px; color: var(--text-muted); }
.aws__badge { border-radius: 6px; padding: 6px 10px; font-size: 12px; font-weight: 700; text-align: center; }
.aws__badge--below { background: rgba(22,163,74,.1);  border: 1px solid rgba(22,163,74,.25);  color: var(--success); }
.aws__badge--above { background: rgba(220,38,38,.1);  border: 1px solid rgba(220,38,38,.25);  color: var(--danger); }
.aws__badge--at    { background: #eef2ff;              border: 1px solid rgba(99,102,241,.25); color: var(--primary); }
.aws__stats { display: flex; flex-direction: column; gap: 0; }
.aws__row {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border);
}
.aws__row:last-child { border-bottom: none; }
.aws__lbl { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.aws__val { font-size: 12px; font-weight: 600; color: var(--text-muted); text-align: right; }
.aws__val--primary { color: var(--primary); font-size: 13px; font-weight: 700; }
.aws__chart-label {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: -4px;
}
.aws__mini-hist { display: flex; align-items: flex-end; gap: 2px; height: 36px; }
.aws__mini-bar {
  flex: 1; background: rgba(99, 102, 241, 0.4);
  border-radius: 2px 2px 0 0; min-height: 2px; transition: background 0.15s; cursor: default;
}
.aws__mini-bar:hover { background: var(--primary); }

/* ── Dark theme overrides for .aws ───────────────────────────── */
[data-theme="dark"] .aws { background: linear-gradient(135deg, #0d1117 0%, #161b27 100%); border-color: rgba(99,102,241,.22); }
[data-theme="dark"] .aws__title { color: #6366f1; }
[data-theme="dark"] .aws__count { color: #334155; }
[data-theme="dark"] .aws__badge--below { background: rgba(52,211,153,.1);  border-color: rgba(52,211,153,.25);  color: #34d399; }
[data-theme="dark"] .aws__badge--above { background: rgba(248,113,113,.1); border-color: rgba(248,113,113,.25); color: #f87171; }
[data-theme="dark"] .aws__badge--at    { background: rgba(99,102,241,.1);  border-color: rgba(99,102,241,.25);  color: #818cf8; }
[data-theme="dark"] .aws__row { border-bottom-color: rgba(255,255,255,.04); }
[data-theme="dark"] .aws__lbl { color: #475569; }
[data-theme="dark"] .aws__val { color: #64748b; }
[data-theme="dark"] .aws__val--primary { color: #a78bfa; }
[data-theme="dark"] .aws__chart-label { color: #334155; }
[data-theme="dark"] .aws__mini-bar { background: rgba(99,102,241,.55); }
[data-theme="dark"] .aws__mini-bar:hover { background: rgba(167,139,250,.85); }

/* ── Analytics responsive ─────────────────────────────────────── */
@media (max-width: 960px) {
  .aw__stats  { grid-template-columns: repeat(3, 1fr); }
  .aw__charts { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .aw { padding: 16px; border-radius: 12px; }
  .aw__stats { grid-template-columns: repeat(2, 1fr); }
  .aw__stat-val { font-size: 15px; }
}

/* ── Freshness badge ──────────────────────────────────────────── */
.freshness-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 600;
  margin-bottom: 8px;
}
.freshness-badge--sold {
  background: #fee2e2; color: var(--danger); border: 1px solid #fca5a5;
}
[data-theme="dark"] .freshness-badge--sold {
  background: rgba(248,113,113,.1); color: #f87171; border-color: rgba(248,113,113,.3);
}

/* ── Inactive banner ──────────────────────────────────────────── */
.inactive-banner {
  display: block;
  background: var(--danger); color: #fff;
  text-align: center; font-weight: 700; font-size: 13px;
  padding: 10px 16px; border-radius: var(--radius);
  margin-bottom: 16px;
}
.card .inactive-banner {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  border-radius: 0; margin-bottom: 0; padding: 5px 12px; font-size: 12px;
}

/* ── Reassign form ────────────────────────────────────────────── */
.detail-aside__reassign {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
}
.reassign-form {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.reassign-form__select {
  flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 13px; background: var(--bg); color: var(--text);
}

/* ── Card action labels (hidden in tile, shown in list) ───────── */
.ca-label { display: none; }
.card__desc { display: none; font-size: 12px; color: var(--text-muted); line-height: 1.4; }

/* ── View toggle buttons ──────────────────────────────────────── */
.view-toggle { display: flex; gap: 2px; margin-left: auto; }
.view-toggle .btn--active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── List view layout ─────────────────────────────────────────── */
html.view-list .card-grid {
  display: flex; flex-direction: column; gap: 8px;
}
html.view-list .card {
  flex-direction: row; min-height: 110px;
}
html.view-list .card > a {
  flex-shrink: 0; width: 140px; display: block;
}
html.view-list .card__image,
html.view-list .card__image--empty {
  width: 140px; height: 100%; aspect-ratio: unset; object-fit: cover;
}
html.view-list .card__body {
  flex: 1; padding: 10px 14px; gap: 4px;
}
html.view-list .card__title {
  -webkit-line-clamp: 1;
}
html.view-list .card__desc {
  display: block; overflow: visible; white-space: normal;
}
html.view-list .ca-label { display: inline; }
html.view-list .card__actions {
  flex-wrap: wrap; gap: 4px;
}

/* ── Currency conversion ──────────────────────────────────────── */
.card__price-uah { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.detail-aside__price-uah { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Language toggle ──────────────────────────────────────────── */
.lang-toggle { display: flex; gap: 2px; }
.lang-toggle .lang-btn { font-size: 11px; padding: 3px 6px; font-weight: 700; letter-spacing: .3px; }
.lang-toggle .btn--active { background: var(--primary); color: #fff; border-color: transparent; }
