:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #14161a;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, white);
  --accent-warm: #f59e0b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --sidebar-w: 232px;
  --sidebar-w-collapsed: 76px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  position: relative;
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Mobile topbar / drawer scrim ---------- */

.mobile-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 260;
}

.mobile-nav-toggle {
  border: none;
  background: transparent;
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-nav-toggle:hover {
  background: var(--bg);
  color: var(--text);
}

.mobile-topbar-brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  z-index: 255;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.sidebar-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  transition: width 280ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow-x: hidden;
  overflow-y: hidden;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  animation: sidebar-slide-in 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
}

@keyframes sidebar-slide-in {
  from {
    transform: translateX(-24px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 6px 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
}

.brand-logo {
  height: 28px;
  width: auto;
  flex-shrink: 0;
  transition: opacity 180ms ease;
}

.sidebar.collapsed .brand-logo {
  opacity: 0;
}

.brand-logo-img {
  height: 44px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  flex-shrink: 0;
  transition: opacity 180ms ease;
}

.sidebar.collapsed .brand-logo-img {
  opacity: 0;
}

.powered-by {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px 10px;
  color: var(--text-muted);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
}

.powered-by svg {
  height: 16px;
  width: auto;
  flex-shrink: 0;
}

.sidebar.collapsed .powered-by {
  opacity: 0;
}

.sidebar-toggle {
  border: none;
  background: transparent;
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 150ms ease, color 150ms ease;
}

.sidebar-toggle:hover {
  background: var(--bg);
  color: var(--text);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  animation: nav-item-in 380ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
  animation-delay: calc(var(--i) * 40ms + 60ms);
  transition: background 150ms ease, color 150ms ease;
}

.nav-parent {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.nav-chevron {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 220ms ease;
}

.nav-group.open > .nav-parent .nav-chevron {
  transform: rotate(180deg);
}

.nav-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height 260ms cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 14px;
}

.nav-group.open .nav-children {
  max-height: 240px;
}

.nav-child {
  font-size: 13px;
  padding: 8px 10px;
}

@keyframes nav-item-in {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.nav-item:hover {
  background: var(--bg);
  color: var(--text);
}

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

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-label {
  transition: opacity 150ms ease;
}

.sidebar.collapsed .nav-label {
  opacity: 0;
}

.sidebar-bottom {
  flex-shrink: 0;
  padding-top: 14px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-select {
  width: 100%;
  text-align: center;
  justify-content: center;
}

select.sidebar-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 34px;
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 11px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%236b7280' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.sidebar.collapsed .sidebar-select {
  display: none;
}

/* ---------- Content ---------- */

.content {
  flex: 1;
  min-width: 0;
  padding: 48px 40px 80px;
}

@media (max-width: 768px) {
  .mobile-topbar {
    display: flex;
  }

  .sidebar-backdrop {
    display: block;
  }

  .sidebar,
  .sidebar.collapsed {
    position: fixed;
    top: 0;
    left: 0;
    width: min(82vw, 300px);
    z-index: 260;
    transform: translateX(-100%);
    box-shadow: none;
    animation: none;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(16, 24, 40, 0.18);
  }

  .sidebar.collapsed .brand-logo,
  .sidebar.collapsed .brand-logo-img,
  .sidebar.collapsed .powered-by,
  .sidebar.collapsed .nav-label {
    opacity: 1;
  }

  body.nav-open-lock {
    overflow: hidden;
  }

  /* ---------- Page chrome ---------- */

  .content {
    padding: 20px 16px 56px;
  }

  .hero h1 {
    font-size: 24px;
  }

  .hero p {
    margin-bottom: 24px;
  }

  .source-config-title {
    font-size: 22px;
  }

  .hero-row {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions {
    flex-wrap: wrap;
    padding-top: 0;
  }

  .hero-actions > .btn {
    flex: 1 1 auto;
  }

  /* ---------- Touch targets ---------- */

  .icon-btn,
  .mobile-nav-toggle {
    width: 40px;
    height: 40px;
  }

  .filter-collapse-toggle {
    width: 36px;
    height: 36px;
  }

  .sidebar-toggle {
    width: 36px;
    height: 36px;
  }

  /* ---------- Filters ---------- */

  .filter-field {
    flex: 1 1 140px;
  }

  .filter-bar .btn {
    flex: 1 1 auto;
  }

  /* ---------- Modals & popovers ---------- */

  .modal-overlay {
    padding: 16px;
  }

  .modal-panel {
    padding: 18px;
    max-height: 85vh;
  }

  .modal-actions {
    flex-wrap: wrap;
  }

  .modal-actions .btn {
    flex: 1 1 auto;
  }

  .popover {
    max-width: calc(100vw - 32px);
  }

  /* ---------- Tables ---------- */

  .listing-table {
    font-size: 12.5px;
  }

  .listing-table thead th,
  .listing-table tbody td {
    padding: 8px 10px;
  }

  /* ---------- Listing detail ---------- */

  .detail-top-actions {
    flex-wrap: wrap;
    flex-shrink: 1;
    width: 100%;
    gap: 10px;
  }

  .detail-score-row {
    flex-wrap: wrap;
  }

  .detail-hero-actions {
    flex-wrap: wrap;
  }

  /* ---------- Duplicate merge candidates ---------- */

  .merge-pair {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .merge-vs {
    align-self: center;
  }

  .merge-actions {
    flex-wrap: wrap;
  }

  /* ---------- Test/rule rows (URL judge, source config) ---------- */

  .test-row,
  .rule-add-row {
    flex-wrap: wrap;
  }

  .test-row .text-input,
  .rule-add-row .text-input {
    flex: 1 1 200px;
  }
}

.page-enter {
  animation: page-in 480ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-note {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 640px;
}

.hero-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  padding-top: 4px;
}

.rescore-threshold-group {
  position: relative;
  display: flex;
  gap: 4px;
}

.rescore-threshold-group[hidden] {
  display: none;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
}

.icon-btn[hidden] {
  display: none;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.12);
  padding: 14px;
}

.rescore-threshold-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rescore-threshold-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.rescore-threshold-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  min-width: 34px;
  text-align: right;
}

.hero h1 {
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}

.source-config-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
}

.hero p {
  color: var(--text-muted);
  font-size: 16px;
  margin: 0 0 40px;
  max-width: 560px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  animation: card-in 460ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
  animation-delay: calc(var(--i) * 70ms + 120ms);
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.08);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 14px;
}

.card h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 500;
}

.card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.card .tag {
  display: inline-block;
  margin-top: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #92400e;
  background: #fef3c7;
  padding: 3px 8px;
  border-radius: 999px;
}

/* ---------- Empty state (stub pages) ---------- */

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 56px 24px;
  text-align: center;
  animation: card-in 460ms cubic-bezier(0.16, 1, 0.3, 1) 120ms backwards;
}

.empty-icon {
  font-size: 30px;
  margin-bottom: 12px;
}

.empty-state h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 500;
}

.empty-state p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- Card as link (Test Bench landing) ---------- */

.card-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.tag-ready {
  color: #166534;
  background: #dcfce7;
}

/* ---------- Buttons & inputs ---------- */

.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 150ms ease, transform 100ms ease, opacity 150ms ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: #eceef1;
}

.btn-danger {
  background: #fee2e2;
  color: #991b1b;
}

.btn-danger:hover:not(:disabled) {
  background: #fecaca;
}

.btn-warning {
  background: #ffedd5;
  color: #9a3412;
}

.btn-warning:hover:not(:disabled) {
  background: #fed7aa;
}

.text-input {
  font-family: inherit;
  font-size: 14px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.text-input.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
}

/* ---------- URL Judge: test panel ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 28px;
  animation: card-in 460ms cubic-bezier(0.16, 1, 0.3, 1) 100ms backwards;
}

.test-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.test-row .text-input {
  flex: 1;
}

.wait-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.wait-field label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.wait-input {
  width: 90px;
}

.result-badge {
  min-width: 64px;
  text-align: center;
  padding: 11px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  transition: background 200ms ease, color 200ms ease;
}

.result-empty {
  background: var(--bg);
  color: var(--text-muted);
}

.result-true {
  background: #dcfce7;
  color: #166534;
}

.result-false {
  background: #fee2e2;
  color: #991b1b;
}

.result-warn {
  background: #fef3c7;
  color: #92400e;
}

.result-detail {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  min-height: 16px;
}

/* ---------- URL Judge: rule lists ---------- */

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.rules-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  animation: card-in 460ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
  animation-delay: 160ms;
}

.rules-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.rules-panel-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
}

.count-pill {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 999px;
  padding: 2px 8px;
}

.rule-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.rule-add-row .text-input {
  flex: 1;
  min-width: 0;
}

.field-error {
  margin: 4px 2px 0;
  font-size: 12px;
  color: #b91c1c;
  min-height: 14px;
}

.rule-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rule-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  background: var(--bg);
  border-radius: 8px;
}

.rule-pattern {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12.5px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.rule-remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: background 150ms ease, color 150ms ease;
}

.rule-remove:hover {
  background: #fee2e2;
  color: #991b1b;
}

.empty-hint {
  display: none;
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.empty-hint.visible {
  display: block;
}

/* ---------- Page Fetcher ---------- */

.fetch-result {
  margin-top: 0;
  animation: card-in 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

.fetch-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px 20px;
  margin-bottom: 18px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.meta-value {
  font-size: 13px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.tab {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 4px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
}

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

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

.output-box {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.output-box.no-scroll {
  max-height: none;
  overflow: visible;
}

.output-box.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
}

.score-trend-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
}

.score-trend-icon {
  font-size: 16px;
  line-height: 1;
}

.score-trend-up {
  color: #166534;
}

.score-trend-down {
  color: #991b1b;
}

.score-trend-flat {
  color: var(--text-muted);
}

.score-trend-overall {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 12.5px;
}

.score-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.score-chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.score-chart-axis-label {
  font-size: 10.5px;
  fill: var(--text-muted);
}

.score-chart-line {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.climate-chart-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 6px;
}

.climate-chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.climate-chart-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

/* ---------- Listing Extractor ---------- */

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

.attr-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.attr-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.attr-value {
  font-size: 13.5px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.feature-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}

.feature-tag {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

.attr-section-title {
  margin: 18px 0 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.attr-section-title:first-child {
  margin-top: 0;
}

.confidence-note {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 12px;
}

.attr-summary {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}

.url-meta {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.textarea-label {
  margin-top: 16px;
}

.textarea-input {
  width: 100%;
  max-width: 760px;
  min-height: 160px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.6;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.save-status {
  font-size: 12.5px;
  color: var(--text-muted);
}

.profile-textarea {
  min-height: 120px;
  overflow-y: hidden;
  resize: none;
}

.history-list {
  margin: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 14px;
}

.history-entry {
  padding: 14px 0;
}

.history-entry:not(:first-child) {
  border-top: 1px solid var(--border);
}

.history-entry-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.history-entry-date {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.pref-source-manual {
  color: #92400e;
  background: #fef3c7;
}

.pref-source-comment {
  color: var(--accent);
  background: var(--accent-soft);
}

.pref-source-coded {
  color: #166534;
  background: #dcfce7;
}

.history-comment-note {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  font-style: italic;
  text-decoration: none;
  margin-bottom: 8px;
}

.history-comment-note:hover {
  color: var(--text);
}

.history-profile-text {
  font-size: 13.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.history-restore-btn {
  margin-top: 12px;
  padding: 6px 12px;
  font-size: 12.5px;
}

.diff-added {
  background: #dcfce7;
  color: #166534;
  text-decoration: none;
  border-radius: 3px;
  padding: 0 2px;
}

.diff-removed {
  background: #fee2e2;
  color: #991b1b;
  border-radius: 3px;
  padding: 0 2px;
}

/* ---------- Listing detail: comments/feedback ---------- */

.comments-tab-body {
  padding-top: 4px;
}

.tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: 6px;
  vertical-align: middle;
}

.tab-dot:not([hidden]) {
  display: inline-block;
}

.comments-subtitle {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--text-muted);
  max-width: 640px;
}

.comment-form-row {
  margin-bottom: 12px;
}

.comment-score-input {
  width: 100px;
}

.comment-textarea {
  min-height: 70px;
  overflow-y: hidden;
  resize: none;
}

.comments-list {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.comment-entry {
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.comment-entry-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.comment-entry-score {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
}

.comment-entry-date {
  font-size: 12px;
  color: var(--text-muted);
}

.comment-influenced {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #166534;
  background: #dcfce7;
  padding: 3px 8px;
  border-radius: 999px;
}

.comment-entry-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.questions-tab-body {
  padding-top: 4px;
}

.qa-pair:not(:last-child) {
  margin-bottom: 10px;
}

.qa-question {
  margin: 0 0 2px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.qa-answer {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* ---------- Preference-change approval modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 23, 0.5);
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal-overlay:not([hidden]) {
  display: flex;
}

.modal-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(16, 24, 40, 0.3);
  padding: 24px;
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 700;
}

.modal-explanation {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

.modal-profile-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

/* ---------- Scoring nudge popup ---------- */

.nudge-modal-panel {
  max-width: 460px;
  text-align: center;
}

.nudge-modal-icon {
  font-size: 32px;
  line-height: 1;
  margin-bottom: 10px;
}

.nudge-modal-panel .modal-title {
  text-align: center;
}

.nudge-modal-panel .modal-explanation {
  text-align: center;
}

.nudge-tabs {
  display: flex;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 18px;
}

.nudge-tabs[hidden] {
  display: none;
}

.nudge-tab {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

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

.nudge-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12);
}

.nudge-modal-panel .field-label,
.nudge-modal-panel .comment-form-row {
  text-align: left;
}

.nudge-modal-actions {
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Listings ---------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 24px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 130px;
}

.filter-field label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.filter-field--form {
  margin-bottom: 14px;
}

.filter-bar .btn {
  height: 41px;
}

.filter-collapse {
  margin-bottom: 24px;
}

.filter-collapse-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.filter-collapse-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.filter-collapse-title.filters-on {
  color: var(--accent);
}

.filter-collapse-toggle {
  border: none;
  background: transparent;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 150ms ease, color 150ms ease;
}

.filter-collapse-toggle:hover {
  background: var(--bg);
  color: var(--text);
}

.filter-collapse-chevron {
  transition: transform 220ms ease;
}

.filter-collapse.open .filter-collapse-chevron {
  transform: rotate(180deg);
}

.filter-collapse-fields.filter-bar {
  max-height: 0;
  margin-bottom: 0;
  overflow: hidden;
  flex-wrap: wrap;
  transition: max-height 280ms cubic-bezier(0.4, 0, 0.2, 1), padding-top 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-collapse.open .filter-collapse-fields.filter-bar {
  max-height: 520px;
  padding-top: 18px;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  animation: card-in 420ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.listing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.listing-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.listing-thumb-col {
  width: 60px;
}

.listing-score-col {
  width: 64px;
}

.listing-user-score-col {
  width: 56px;
  text-align: center;
}

.th-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  color: inherit;
  cursor: pointer;
}

.th-sort-btn:hover {
  color: var(--text);
}

.sort-arrow {
  display: inline-block;
  font-size: 9px;
  opacity: 0.35;
  line-height: 1;
}

.sortable-th.sort-active .sort-arrow {
  opacity: 1;
  color: var(--accent, var(--text));
}

.listing-user-score-cell {
  text-align: center;
  color: var(--text-muted);
}

.listing-table tbody tr:not(:last-child) td {
  border-bottom: 1px solid var(--border);
}

.listing-table tbody td {
  padding: 10px 14px;
  vertical-align: middle;
  color: var(--text);
}

.listing-row {
  cursor: pointer;
  transition: background 150ms ease;
}

.listing-row:hover {
  background: var(--bg);
}

.listing-row td {
  white-space: nowrap;
}

.listing-thumb-cell {
  width: 60px;
}

.listing-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background-color: var(--bg);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.listing-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--accent-soft);
}

.listing-score-cell {
  text-align: center;
}

.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: default;
  padding: 0;
  transition: transform 150ms ease;
}

/* A <button class="score-badge"> is a stale score — still clickable to re-score. */
button.score-badge {
  cursor: pointer;
}

button.score-badge:hover:not(:disabled) {
  transform: scale(1.08);
}

.score-stale {
  background: var(--accent-soft);
  color: var(--accent);
}

.score-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease;
}

.score-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.score-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.listing-title-cell {
  white-space: normal;
  max-width: 260px;
}

.listing-title-line {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  /* Reserves ~1 extra character of width so the trailing blue dot never
     gets squeezed to half-visible against the next column. */
  padding-right: 1ch;
}

.listing-title-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}

.listing-title-line .tab-dot {
  flex-shrink: 0;
}

.listing-badge {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.listing-badge-new {
  color: var(--accent-warm);
  background: #fef3c7;
}

.listing-location {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.listing-hidden-note {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 2px;
  white-space: normal;
}

.listing-price-cell {
  font-weight: 500;
}

/* ---------- Merge review ---------- */

.merge-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.merge-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.merge-panel-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
}

.merge-candidate {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.merge-candidate:not(:last-child) {
  margin-bottom: 2px;
}

.merge-pair {
  display: flex;
  align-items: center;
  gap: 14px;
}

.merge-side {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  padding: 6px;
  border-radius: 8px;
  transition: background 150ms ease;
}

.merge-side:hover {
  background: var(--bg);
}

.merge-thumb {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 8px;
  background-color: var(--bg);
  background-size: cover;
  background-position: center;
}

.merge-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--accent-soft);
}

.merge-side-body {
  min-width: 0;
}

.merge-side-title {
  font-size: 13.5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merge-side-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merge-side-location {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merge-side-source {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merge-vs {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.merge-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  font-size: 12px;
}

.merge-match {
  color: #166534;
}

.merge-conflict-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.merge-conflict {
  color: #991b1b;
  background: #fef2f2;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.merge-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

/* ---------- Failed extractions ---------- */

.failure-row td {
  padding: 16px 14px;
}

.failure-url-cell {
  max-width: 420px;
}

.failure-url-cell a {
  color: var(--text);
  font-size: 13px;
}

.failure-when {
  color: var(--text-muted);
  font-size: 12.5px;
}

.failure-actions-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.failure-actions-cell .btn {
  padding: 6px 12px;
  font-size: 12.5px;
}

.failure-source-coded {
  color: var(--accent);
  background: var(--accent-soft);
}

.failure-source-manual {
  color: #92400e;
  background: #fef3c7;
}

.failure-source-email {
  color: #166534;
  background: #dcfce7;
}

.blocked-detail {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ---------- Listing detail page ---------- */

.detail-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.detail-top-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
  text-decoration: none;
  transition: color 150ms ease;
}

.back-link:hover {
  color: var(--text);
}

.back-link.nudge-armed {
  color: var(--accent);
}

.back-link.nudge-armed:hover {
  color: var(--accent);
}

.config-picker-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.config-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 150ms ease;
}

.config-picker-item:hover {
  border-color: var(--accent);
}

.detail-hero {
  display: flex;
  gap: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
  animation: card-in 460ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.detail-hero-media {
  display: flex;
  flex-direction: column;
  width: 340px;
  min-width: 340px;
}

.detail-hero-media.no-image {
  width: auto;
  min-width: 0;
}

.detail-hero-image {
  display: block;
  position: relative;
  min-height: 260px;
  background-color: var(--bg);
  background-size: cover;
  background-position: center;
  cursor: pointer;
}

.detail-hero-image[hidden] {
  display: none;
}

.detail-image-edit-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.18);
}

.detail-source-badge {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 6px 10px;
  border-radius: 20px;
  background: rgba(16, 24, 40, 0.65);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  backdrop-filter: blur(2px);
}

.detail-hero-body {
  flex: 1;
  padding: 28px 28px 28px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.detail-hero-media.no-image + .detail-hero-body {
  padding-left: 28px;
}

.detail-hero-actions {
  display: flex;
  align-self: flex-start;
  gap: 8px;
  margin-bottom: 14px;
}

.detail-hero-body h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.detail-score-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.detail-score-row .score-badge {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  font-size: 14px;
  cursor: default;
}

.detail-score-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.detail-score-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.detail-score-reasoning {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

.detail-title-link {
  color: inherit;
  text-decoration: none;
}

.detail-title-link:hover {
  text-decoration: underline;
}

.detail-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.detail-location {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.detail-location a {
  color: inherit;
  text-decoration: none;
}

.detail-location a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.detail-meta {
  font-size: 13.5px;
  color: var(--text);
  font-weight: 500;
}

@media (max-width: 720px) {
  .detail-hero {
    flex-direction: column;
  }

  .detail-hero-media {
    width: 100%;
    min-width: 0;
  }

  .detail-hero-body {
    padding: 20px;
  }
}

/* ---------- AI Spend ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.usage-panel {
  margin-top: 20px;
}

.usage-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.usage-panel h3 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 500;
}

.usage-panel-head h3 {
  margin: 0;
}

.chart-wrap {
  position: relative;
  overflow-x: auto;
}

.chart-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-bar {
  fill: var(--accent);
  cursor: pointer;
  transition: opacity 120ms ease;
}

.chart-bar:hover {
  opacity: 0.85;
}

.chart-gridline {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-axis-text {
  fill: var(--text-muted);
  font-size: 10.5px;
  font-family: inherit;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chart-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.12);
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 100ms ease, transform 100ms ease;
  z-index: 50;
  white-space: nowrap;
  max-width: 280px;
}

.chart-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.chart-tooltip-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.chart-tooltip-desc {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  white-space: normal;
}

/* ---------- Sources ---------- */

.panel-title {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 500;
}

.source-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.source-form-field-wide {
  grid-column: 1 / -1;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.checkbox-field .checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}

.checkbox-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.checkbox-field .field-hint {
  margin-left: 24px;
}

.test-result {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.test-result > .empty-hint {
  margin-top: 0;
}

.notice-box {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-warm);
  border-radius: 10px;
  background: var(--bg);
}

.notice-box-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
}

.test-result-summary {
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 8px;
}

.test-result.result-error .test-result-summary {
  color: #991b1b;
}

.test-result-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.test-result-item {
  font-size: 13px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.test-result-item a {
  color: var(--text);
  text-decoration: none;
}

.test-result-item a:hover {
  color: var(--accent);
}

.test-result-item-meta {
  color: var(--text-muted);
  white-space: nowrap;
}

.source-table td {
  padding: 10px 14px;
  vertical-align: middle;
  color: var(--text);
}

.source-cell-title {
  min-width: 180px;
}

.source-row-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
}

.source-actions-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.source-actions-cell .btn {
  padding: 6px 12px;
  font-size: 12.5px;
}

/* ---------- Sources page: per-source "Listings" block ---------- */

.source-listings-cell {
  min-width: 260px;
}

.source-action-col {
  width: 56px;
}

.source-action-cell {
  text-align: right;
}

.source-action-cell .source-activate-btn {
  padding: 6px 12px;
  font-size: 12.5px;
}

.source-listings-block {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
}

.source-listings-block .btn {
  padding: 6px 12px;
  font-size: 12.5px;
}

.source-listings-building {
  color: var(--text-muted);
  font-style: italic;
}

.spinner-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: spinner-dot-pulse 1.1s ease-in-out infinite;
}

@keyframes spinner-dot-pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

/* ---------- Icon action buttons (table row actions) ---------- */

.icon-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.icon-action-btn[hidden] {
  display: none;
}

.icon-action-btn:hover:not(:disabled) {
  background: var(--bg);
  color: var(--accent);
  border-color: var(--accent);
}

.icon-action-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.icon-action-btn.icon-action-danger:hover:not(:disabled) {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

/* ---------- Truncated table cell text (min ~15 characters visible) ---------- */

.cell-truncate {
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  vertical-align: bottom;
}

.source-detail-row td {
  padding: 0 14px 14px;
  border-bottom: 1px solid var(--border);
}

.source-card-url {
  font-size: 12.5px;
  color: var(--text-muted);
  text-decoration: none;
  word-break: break-all;
}

.source-card-url:hover {
  color: var(--accent);
}

.source-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.source-check-result {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.status-ready {
  color: #166534;
  background: #dcfce7;
}

.status-pending {
  color: #92400e;
  background: #fef3c7;
}

.status-failed {
  color: #991b1b;
  background: #fee2e2;
}

.status-blacklisted {
  color: #374151;
  background: #e5e7eb;
}

.status-scheduled {
  color: #1d4ed8;
  background: #dbeafe;
}

.source-extract-block {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.source-row-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.source-schedule-select {
  padding: 7px 10px;
  font-size: 12.5px;
  min-width: 100px;
}

.source-history {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.run-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
}

.run-row:not(:last-child) {
  margin-bottom: 8px;
}

.run-row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.run-row-time {
  font-size: 12.5px;
  font-weight: 500;
}

.run-row-summary {
  font-size: 12px;
  color: var(--text-muted);
}

.run-row-url {
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 6px;
  padding: 2px 6px;
  overflow-wrap: anywhere;
}

.run-row-items {
  margin-top: 10px;
  display: none;
}

.run-row.expanded .run-row-items {
  display: block;
}

.run-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
}

.run-item-url {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  text-decoration: none;
}

.run-item-url:hover {
  color: var(--accent);
}

.run-item-detail {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 1px;
}

.run-item-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.outcome-added {
  color: #166534;
  background: #dcfce7;
}

.outcome-blocked {
  color: #991b1b;
  background: #fee2e2;
}

.outcome-excluded {
  color: #92400e;
  background: #fef3c7;
}

.outcome-failed {
  color: #991b1b;
  background: #fee2e2;
}

.outcome-filtered,
.outcome-pending {
  color: var(--text-muted);
  background: var(--bg);
}

/* ---------- Error page ---------- */

.error-page {
  min-height: calc(100vh - 96px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.error-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 460px;
  width: 100%;
  padding: 48px 40px;
  text-align: center;
  animation: card-in 460ms cubic-bezier(0.16, 1, 0.3, 1) 80ms backwards;
}

.error-icon {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 16px;
  display: inline-block;
  animation: error-swing 2.6s ease-in-out infinite;
  transform-origin: top center;
}

@keyframes error-swing {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

.error-code {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.error-title {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 700;
}

.error-message {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.error-detail {
  margin: 16px 0 0;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
  font-style: italic;
}

.error-actions {
  margin-top: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- Auth / landing ---------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 32px 24px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.auth-logo {
  max-width: 100%;
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(37, 99, 235, 0.18));
}

.auth-name {
  margin: 0;
  line-height: 0;
}

.beta-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 4px 10px;
}

.auth-tagline {
  max-width: 340px;
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}

.auth-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 0 12px;
}

.auth-card {
  width: 100%;
}

.auth-btn-row {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

@media (max-width: 420px) {
  .auth-shell {
    padding: 24px 16px;
    gap: 22px;
  }

  .auth-name {
    font-size: 26px;
  }

  .auth-tagline {
    font-size: 13px;
  }

  .auth-card {
    padding: 20px;
  }

  .auth-btn-row .btn {
    width: 100%;
  }
}

.welcome-popup {
  position: fixed;
  /* Sits below the language switcher (top: 16px, ~34px tall) so the two
     don't overlap in the common case; z-index still wins over it (210)
     so the welcome message stays on top if they ever do collide. */
  top: 64px;
  right: 24px;
  z-index: 220;
  max-width: 360px;
  opacity: 0;
  transform: translateY(-12px) scale(0.98);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.welcome-popup.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.welcome-popup-card {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.16);
  padding: 16px 40px 16px 16px;
}

.welcome-popup-icon {
  flex: none;
  font-size: 26px;
  line-height: 1;
  animation: welcome-wave 1.6s ease-in-out 0.2s 2;
  transform-origin: 70% 70%;
}

@keyframes welcome-wave {
  0%, 100% { transform: rotate(0deg); }
  15% { transform: rotate(14deg); }
  30% { transform: rotate(-8deg); }
  45% { transform: rotate(14deg); }
  60% { transform: rotate(-4deg); }
  75% { transform: rotate(10deg); }
}

.welcome-popup-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

.welcome-popup-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
}

.welcome-popup-close:hover {
  color: var(--text);
}

@media (max-width: 640px) {
  .welcome-popup {
    left: 16px;
    right: 16px;
    top: 56px;
    max-width: none;
  }
}

/* ---------- Language switcher ---------- */

.lang-switcher {
  position: relative;
  width: 100%;
}

.lang-intro[hidden] {
  display: none;
}

.lang-intro {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 210;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.16);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  animation: page-in 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.lang-tooltips {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lang-tooltips .lang-intro {
  position: static;
}

.lang-intro button {
  flex: none;
  border: none;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
}

@media (max-width: 640px) {
  .lang-intro {
    max-width: calc(100vw - 96px);
  }
}

/* Onboarding tour */

.tour-highlight {
  position: fixed;
  border-radius: 10px;
  box-shadow: 0 0 0 3px var(--accent-warm), 0 0 0 9999px rgba(15, 18, 23, 0.4);
  z-index: 401;
  pointer-events: none;
}

.tour-bubble {
  position: fixed;
  z-index: 403;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(16, 24, 40, 0.35);
  padding: 16px 18px;
  width: 280px;
}

.tour-bubble-text {
  margin: 0 0 14px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
}

.tour-bubble-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tour-skip-btn {
  border: none;
  background: none;
  padding: 0;
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.tour-skip-btn:hover {
  color: var(--text);
}

.tour-next-btn {
  padding: 8px 18px;
  font-size: 13.5px;
}

/* ---------- Marketing pages ---------- */

.marketing-page {
  min-height: 100vh;
  background: var(--bg);
}

.marketing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 24px;
}

.marketing-logo {
  display: flex;
  align-items: center;
}

.marketing-logo svg {
  height: 34px;
  width: auto;
}

.marketing-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.marketing-nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
}

.marketing-nav-link:hover {
  color: var(--text);
}

.marketing-hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items: center;
}

.marketing-hero-copy h1 {
  font-size: 42px;
  line-height: 1.15;
  margin: 16px 0;
  letter-spacing: -0.01em;
}

.marketing-hero-copy .lede {
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 0 28px;
}

.marketing-hero-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.marketing-hero-actions .btn {
  padding: 13px 24px;
  font-size: 15px;
}

.marketing-hero-note {
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.marketing-illustration {
  width: 100%;
  height: auto;
}

.marketing-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 60px 24px;
  border-top: 1px solid var(--border);
}

.marketing-section-header {
  text-align: center;
  max-width: 560px;
  margin: 0 auto 40px;
}

.marketing-section-header h2 {
  font-size: 28px;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}

.marketing-section-header p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0;
}

.marketing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.marketing-grid .card {
  cursor: default;
}

.marketing-grid .card:hover {
  transform: none;
  box-shadow: var(--shadow);
}

.marketing-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  counter-reset: step;
}

.marketing-step {
  position: relative;
  padding-left: 4px;
}

.marketing-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 14px;
}

.marketing-step h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.marketing-step p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}

.marketing-cta {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 48px 32px;
}

.marketing-cta h2 {
  font-size: 26px;
  margin: 0 0 12px;
}

.marketing-cta p {
  font-size: 15px;
  color: var(--text-muted);
  margin: 0 0 24px;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.marketing-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 36px 24px 48px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.marketing-footer a {
  color: var(--text-muted);
}

@media (max-width: 860px) {
  .marketing-hero {
    grid-template-columns: 1fr;
    padding-top: 20px;
    text-align: center;
  }

  .marketing-hero-copy .lede {
    margin-left: auto;
    margin-right: auto;
  }

  .marketing-hero-actions {
    justify-content: center;
  }

  .marketing-illustration {
    max-width: 360px;
    margin: 0 auto;
  }

  .marketing-grid,
  .marketing-steps {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .marketing-header {
    padding: 18px 16px;
  }

  .marketing-nav {
    gap: 12px;
  }

  .marketing-nav-link {
    font-size: 13px;
  }

  .marketing-hero-copy h1 {
    font-size: 30px;
  }

  .marketing-section {
    padding: 44px 16px;
  }

  .marketing-cta {
    padding: 36px 20px;
  }
}
