/* ── CSS variables ── */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3350;
  --text: #e2e8f0;
  --muted: #8892b0;
  --accent: #7c6ef9;
  --accent-hover: #6c5ee9;
  --danger: #e05252;
  --success: #4caf7d;
  --warn: #f0a84e;
  --info: #4ea8de;
  --radius: 8px;
}

[data-theme="light"] {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface2: #eef0f8;
  --border: #d0d5e8;
  --text: #1a1d2e;
  --muted: #64748b;
}

/* ── Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ── Navbar ── */
.navbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;

  & .nav {
    &-brand {
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      font-weight: 700;
      font-size: 1.1rem;
      color: var(--text);
    }
    &-links {
      display: flex;
      gap: 1rem;
      list-style: none;
      & a {
        color: var(--muted);
        font-size: 0.9rem;
        &:hover {
          color: var(--text);
        }
      }
    }
  }

  #theme-toggle {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
  }
}

/* ── Container ── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Breadcrumb ── */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1.5rem;

  a {
    color: var(--muted);
  }
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;

  &-header h2 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
  }
  &-actions {
    margin-top: 1rem;
  }
}

/* ── Stat row ── */
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;

  &-new {
    background: var(--info);
    color: #fff;
  }
  &-text_filtered {
    background: var(--warn);
    color: #1a1d2e;
  }
  &-vision_filtered {
    background: var(--warn);
    color: #1a1d2e;
  }
  &-notified {
    background: var(--success);
    color: #fff;
  }
  &-approved {
    background: var(--success);
    color: #fff;
  }
  &-rejected {
    background: var(--danger);
    color: #fff;
  }
  &-used_cars {
    background: #3a6ea8;
    color: #fff;
  }
  &-apartments {
    background: #4a7a5c;
    color: #fff;
  }
  &-unknown {
    background: var(--surface2);
    color: var(--muted);
  }
  &-warn {
    background: var(--warn);
    color: #1a1d2e;
  }
}

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 0.45em 1em;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  text-decoration: none;

  &:hover {
    background: var(--accent-hover);
    text-decoration: none;
  }

  &-sm {
    padding: 0.3em 0.75em;
    font-size: 0.8rem;
  }
  &-xs {
    padding: 0.2em 0.5em;
    font-size: 0.75rem;
  }
  &-danger {
    background: var(--danger);
  }
  &-danger:hover {
    background: #c94444;
  }
}

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.5rem;

  select,
  input {
    padding: 0.35em 0.6em;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
  }
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;

  th {
    background: var(--surface2);
    color: var(--muted);
    font-weight: 600;
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
  }

  td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
  }

  tr:hover td {
    background: var(--surface2);
  }
}

.actions {
  display: flex;
  gap: 0.4rem;
}

/* ── Namespace 2-column layout ── */
.ns-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* ── Run sidebar ── */
.run-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  position: sticky;
  top: 1rem;

  .sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
  }
  .sidebar-header h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
  }
  .run-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 70vh;
    overflow-y: auto;
  }
  .run-item {
    border-radius: 4px;
  }
  .run-item.active {
    background: var(--accent);
  }
  .run-item.active .run-btn {
    color: #fff;
  }
  .run-btn {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    font-size: 0.82rem;
    color: var(--muted);
    border-radius: 4px;
    font-family: monospace;
  }
  .run-btn:hover {
    background: var(--surface2);
    color: var(--text);
  }
}

.run-main {
  min-height: 60vh;
}

/* ── HTMX loading indicator ── */
.htmx-indicator {
  display: none;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}
.htmx-request .htmx-indicator {
  display: block;
}

/* ── Run meta bar ── */
.run-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.run-ts {
  font-family: monospace;
}

/* ── Listing grid ── */
.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.listing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;

  .listing-card-link {
    display: block;
    color: inherit;
  }
  .listing-card-link:hover {
    text-decoration: none;
  }
  .listing-body {
    padding: 0.9rem;
  }
  .listing-title {
    font-weight: 600;
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text);
  }
  .listing-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 0.4rem;
  }
  .scores {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.4rem;
  }
  .listing-img-wrap {
    width: 100%;
    aspect-ratio: 4/3;
    overflow: hidden;
    background: var(--surface2);
  }
  .listing-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .listing-subtitle {
    font-size: 0.78rem;
    color: var(--muted);
    margin: 0.25rem 0 0.4rem;
  }
  .price-rating {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
  }
  .price-good {
    color: var(--success);
  }
  .price-high {
    color: var(--danger);
  }
  .price-fair {
    color: var(--warn);
  }
  .card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .card-footer-main {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .card-source-link {
    font-size: 0.78rem;
    color: var(--muted);
  }
}

/* ── Listing detail ── */
.detail-shell {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;

  .detail-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.95fr);
    gap: 1.25rem;
    align-items: start;
  }
  .detail-gallery,
  .detail-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
  .detail-gallery {
    padding: 1rem;
  }
  .detail-gallery-stage {
    position: relative;
  }
  .detail-main-image-wrap {
    overflow: hidden;
    border-radius: calc(var(--radius) - 2px);
    background: var(--surface2);
  }
  .detail-main-image {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
  }
  .detail-gallery-main {
    border-radius: calc(var(--radius) - 2px);
    overflow: hidden;
  }
  .detail-gallery-slide {
    background: var(--surface2);
  }
  .detail-thumb-swiper {
    margin-top: 0.75rem;
  }
  .detail-thumb {
    display: block;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface2);
    cursor: pointer;
    padding: 0;
  }
  .detail-thumb img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
  }
  .detail-thumb.swiper-slide-thumb-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent);
  }
  .detail-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 2.4rem;
    height: 2.4rem;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 17, 23, 0.78);
    color: #fff;
    cursor: pointer;
  }
  .detail-gallery-nav::before {
    display: block;
    font-size: 1.2rem;
    line-height: 1;
  }
  .detail-gallery-prev {
    left: 0.75rem;
  }
  .detail-gallery-prev::before {
    content: "‹";
  }
  .detail-gallery-next {
    right: 0.75rem;
  }
  .detail-gallery-next::before {
    content: "›";
  }
  .detail-gallery-pagination {
    position: absolute;
    left: 50%;
    bottom: 0.85rem;
    transform: translateX(-50%);
    z-index: 2;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: rgba(15, 17, 23, 0.7);
    color: #fff;
    font-size: 0.8rem;
  }
  .detail-zoom-btn {
    position: absolute;
    right: 0.85rem;
    top: 0.85rem;
    z-index: 2;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 17, 23, 0.76);
    color: #fff;
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    font-size: 0.82rem;
  }
  .detail-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--muted);
  }
  .detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
  .detail-panel {
    padding: 1rem;
  }
  .detail-title-panel h1 {
    font-size: 1.55rem;
    margin-bottom: 0.4rem;
  }
  .detail-price {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
  }
  .detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.85rem;
  }
  .detail-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
  }
  .detail-section-header h2 {
    margin: 0;
  }
  .detail-inline-toggle {
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
    font-size: 0.82rem;
  }
  .detail-description-shell {
    position: relative;
  }
  .detail-list {
    display: grid;
    gap: 0.6rem;
  }
  .detail-list div {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 0.75rem;
  }
  .detail-list dt {
    color: var(--muted);
    font-size: 0.82rem;
  }
  .detail-list dd {
    color: var(--text);
  }
  .detail-list-compact div {
    grid-template-columns: 110px 1fr;
  }
  .detail-section h2 {
    margin-top: 0;
    margin-bottom: 0.9rem;
  }
  .detail-description {
    white-space: pre-line;
    color: var(--text);
    transition: max-height 160ms ease;
  }
  .detail-description.is-collapsed {
    max-height: 11rem;
    overflow: hidden;
    position: relative;
    -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 72%, transparent 100%);
  }
  .detail-description.is-expanded {
    max-height: none;
    -webkit-mask-image: none;
    mask-image: none;
  }
  .feature-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
  }
  .feature-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: var(--surface2);
    border: 1px solid var(--border);
    font-size: 0.82rem;
  }
  .feature-chip-muted {
    color: var(--muted);
  }
  .eval-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
  }
  .eval-card {
    padding: 1.15rem 1.15rem 1.05rem;
  }
  .eval-card h3 {
    margin: 0;
    font-size: 1rem;
  }
  .eval-header {
    display: flex;
    justify-content: space-between;
    gap: 0.9rem;
    align-items: flex-start;
    margin-bottom: 0.55rem;
  }
  .eval-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-end;
  }
  .eval-summary {
    margin: 0.95rem 0 1rem;
    padding: 0.8rem 0.9rem;
    border-left: 3px solid var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, var(--surface2));
    border-radius: 0 8px 8px 0;
    font-weight: 600;
  }
  .eval-metrics {
    margin-bottom: 1rem;
  }
  .eval-metrics div {
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    background: var(--surface2);
    border-bottom: 0;
  }
  .fact-list {
    margin: 1rem 0 0 1.25rem;
    color: var(--text);
    display: grid;
    gap: 0.65rem;
  }
  .fact-list li {
    padding-left: 0.15rem;
  }
  .detail-json {
    margin-top: 0.9rem;
  }
  .detail-json summary {
    cursor: pointer;
    color: var(--muted);
  }
  .json-block {
    margin-top: 0.7rem;
    padding: 0.85rem;
    border-radius: 6px;
    background: var(--surface2);
    border: 1px solid var(--border);
    overflow-x: auto;
    font-size: 0.78rem;
    line-height: 1.5;
  }
}

@media (max-width: 700px) {
  .ns-layout {
    grid-template-columns: 1fr;
  }
  .run-sidebar {
    position: static;
  }
}

@media (max-width: 920px) {
  .detail-shell {
    .detail-hero {
      grid-template-columns: 1fr;
    }
  }
}

@media (max-width: 640px) {
  .detail-shell {
    .detail-list div {
      grid-template-columns: 1fr;
      gap: 0.2rem;
    }
    .detail-gallery-nav {
      display: none;
    }
  }
}

/* ── Profile form ── */
.profile-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-top: 1.5rem;

  label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.875rem;
  }
  input {
    padding: 0.4em 0.6em;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
  }
}

/* ── Pagination ── */
.pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 1.25rem;
}

/* ── Misc ── */
.muted {
  color: var(--muted);
  font-size: 0.875rem;
}
.mono {
  font-family: monospace;
  font-size: 0.82rem;
}
.error {
  color: var(--danger);
}
h1 {
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
}
h2 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.75rem;
} /* ── CSS variables ── */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3350;
  --text: #e2e8f0;
  --muted: #8892b0;
  --accent: #7c6ef9;
  --accent-hover: #6c5ee9;
  --danger: #e05252;
  --success: #4caf7d;
  --warn: #f0a84e;
  --info: #4ea8de;
  --radius: 8px;
}

[data-theme="light"] {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface2: #eef0f8;
  --border: #d0d5e8;
  --text: #1a1d2e;
  --muted: #64748b;
}

/* ── Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ── Navbar ── */
.navbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;

  .nav-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
  }
  .nav-links {
    display: flex;
    gap: 1rem;
    list-style: none;
  }
  .nav-links a {
    color: var(--muted);
    font-size: 0.9rem;
  }
  .nav-links a:hover {
    color: var(--text);
  }
  #theme-toggle {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
  }
}

/* ── Container ── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Breadcrumb ── */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1.5rem;

  a {
    color: var(--muted);
  }
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;

  .card-header h2 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
  }
  .card-actions {
    margin-top: 1rem;
  }
}

/* ── Stat row ── */
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-new {
  background: var(--info);
  color: #fff;
}
.badge-text_filtered {
  background: var(--warn);
  color: #1a1d2e;
}
.badge-vision_filtered {
  background: var(--warn);
  color: #1a1d2e;
}
.badge-notified {
  background: var(--success);
  color: #fff;
}
.badge-approved {
  background: var(--success);
  color: #fff;
}
.badge-rejected {
  background: var(--danger);
  color: #fff;
}
.badge-used_cars {
  background: #3a6ea8;
  color: #fff;
}
.badge-apartments {
  background: #4a7a5c;
  color: #fff;
}
.badge-unknown {
  background: var(--surface2);
  color: var(--muted);
}
.badge-warn {
  background: var(--warn);
  color: #1a1d2e;
}

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 0.45em 1em;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  text-decoration: none;

  &:hover {
    background: var(--accent-hover);
    text-decoration: none;
  }
}

.btn-sm {
  padding: 0.3em 0.75em;
  font-size: 0.8rem;
}
.btn-xs {
  padding: 0.2em 0.5em;
  font-size: 0.75rem;
}
.btn-danger {
  background: var(--danger);
}
.btn-danger:hover {
  background: #c94444;
}

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.5rem;

  select,
  input {
    padding: 0.35em 0.6em;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
  }
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;

  th {
    background: var(--surface2);
    color: var(--muted);
    font-weight: 600;
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
  }

  td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
  }

  tr:hover td {
    background: var(--surface2);
  }
}

.actions {
  display: flex;
  gap: 0.4rem;
}

/* ── Namespace 2-column layout ── */
.ns-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* ── Run sidebar ── */
.run-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  position: sticky;
  top: 1rem;

  .sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
  }
  .sidebar-header h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
  }
  .run-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 70vh;
    overflow-y: auto;
  }
  .run-item {
    border-radius: 4px;
  }
  .run-item.active {
    background: var(--accent);
  }
  .run-item.active .run-btn {
    color: #fff;
  }
  .run-btn {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    font-size: 0.82rem;
    color: var(--muted);
    border-radius: 4px;
    font-family: monospace;
  }
  .run-btn:hover {
    background: var(--surface2);
    color: var(--text);
  }
}

.run-main {
  min-height: 60vh;
}

/* ── HTMX loading indicator ── */
.htmx-indicator {
  display: none;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}
.htmx-request .htmx-indicator {
  display: block;
}

/* ── Run meta bar ── */
.run-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.run-ts {
  font-family: monospace;
}

/* ── Listing grid ── */
.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.listing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;

  .listing-card-link {
    display: block;
    color: inherit;
  }
  .listing-card-link:hover {
    text-decoration: none;
  }
  .listing-body {
    padding: 0.9rem;
  }
  .listing-title {
    font-weight: 600;
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text);
  }
  .listing-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 0.4rem;
  }
  .scores {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.4rem;
  }
  .listing-img-wrap {
    width: 100%;
    aspect-ratio: 4/3;
    overflow: hidden;
    background: var(--surface2);
  }
  .listing-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .listing-subtitle {
    font-size: 0.78rem;
    color: var(--muted);
    margin: 0.25rem 0 0.4rem;
  }
  .price-rating {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
  }
  .price-good {
    color: var(--success);
  }
  .price-high {
    color: var(--danger);
  }
  .price-fair {
    color: var(--warn);
  }
  .card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .card-footer-main {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .card-source-link {
    font-size: 0.78rem;
    color: var(--muted);
  }
}

/* ── Listing detail ── */
.detail-shell {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;

  .detail-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.95fr);
    gap: 1.25rem;
    align-items: start;
  }
  .detail-gallery,
  .detail-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
  .detail-gallery {
    padding: 1rem;
  }
  .detail-gallery-stage {
    position: relative;
  }
  .detail-main-image-wrap {
    overflow: hidden;
    border-radius: calc(var(--radius) - 2px);
    background: var(--surface2);
  }
  .detail-main-image {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
  }
  .detail-gallery-main {
    border-radius: calc(var(--radius) - 2px);
    overflow: hidden;
  }
  .detail-gallery-slide {
    background: var(--surface2);
  }
  .detail-thumb-swiper {
    margin-top: 0.75rem;
  }
  .detail-thumb {
    display: block;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface2);
    cursor: pointer;
    padding: 0;
  }
  .detail-thumb img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
  }
  .detail-thumb.swiper-slide-thumb-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent);
  }
  .detail-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 2.4rem;
    height: 2.4rem;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 17, 23, 0.78);
    color: #fff;
    cursor: pointer;

    &::before {
      display: block;
      font-size: 1.2rem;
      line-height: 1;
    }
  }
  .detail-gallery-prev {
    left: 0.75rem;
  }
  .detail-gallery-prev::before {
    content: "‹";
  }
  .detail-gallery-next {
    right: 0.75rem;
  }
  .detail-gallery-next::before {
    content: "›";
  }
  .detail-gallery-pagination {
    position: absolute;
    left: 50%;
    bottom: 0.85rem;
    transform: translateX(-50%);
    z-index: 2;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: rgba(15, 17, 23, 0.7);
    color: #fff;
    font-size: 0.8rem;
  }
  .detail-zoom-btn {
    position: absolute;
    right: 0.85rem;
    top: 0.85rem;
    z-index: 2;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 17, 23, 0.76);
    color: #fff;
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    font-size: 0.82rem;
  }
  .detail-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--muted);
  }
  .detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
  .detail-panel {
    padding: 1rem;
  }
  .detail-title-panel h1 {
    font-size: 1.55rem;
    margin-bottom: 0.4rem;
  }
  .detail-price {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
  }
  .detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.85rem;
  }
  .detail-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
  }
  .detail-section-header h2 {
    margin: 0;
  }
  .detail-inline-toggle {
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
    font-size: 0.82rem;
  }
  .detail-description-shell {
    position: relative;
  }
  .detail-list {
    display: grid;
    gap: 0.6rem;
  }
  .detail-list div {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 0.75rem;
  }
  .detail-list dt {
    color: var(--muted);
    font-size: 0.82rem;
  }
  .detail-list dd {
    color: var(--text);
  }
  .detail-list-compact div {
    grid-template-columns: 110px 1fr;
  }
  .detail-section h2 {
    margin-top: 0;
    margin-bottom: 0.9rem;
  }
  .detail-description {
    white-space: pre-line;
    color: var(--text);
    transition: max-height 160ms ease;
  }
  .detail-description.is-collapsed {
    max-height: 11rem;
    overflow: hidden;
    position: relative;
    -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 72%, transparent 100%);
  }
  .detail-description.is-expanded {
    max-height: none;
    -webkit-mask-image: none;
    mask-image: none;
  }
  .feature-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
  }
  .feature-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: var(--surface2);
    border: 1px solid var(--border);
    font-size: 0.82rem;
  }
  .feature-chip-muted {
    color: var(--muted);
  }
  .eval-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
  }
  .eval-card {
    padding: 1.15rem 1.15rem 1.05rem;
  }
  .eval-card h3 {
    margin: 0;
    font-size: 1rem;
  }
  .eval-header {
    display: flex;
    justify-content: space-between;
    gap: 0.9rem;
    align-items: flex-start;
    margin-bottom: 0.55rem;
  }
  .eval-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-end;
  }
  .eval-summary {
    margin: 0.95rem 0 1rem;
    padding: 0.8rem 0.9rem;
    border-left: 3px solid var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, var(--surface2));
    border-radius: 0 8px 8px 0;
    font-weight: 600;
  }
  .eval-metrics {
    margin-bottom: 1rem;
  }
  .eval-metrics div {
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    background: var(--surface2);
    border-bottom: 0;
  }
  .fact-list {
    margin: 1rem 0 0 1.25rem;
    color: var(--text);
    display: grid;
    gap: 0.65rem;
  }
  .fact-list li {
    padding-left: 0.15rem;
  }
  .detail-json {
    margin-top: 0.9rem;
  }
  .detail-json summary {
    cursor: pointer;
    color: var(--muted);
  }
  .json-block {
    margin-top: 0.7rem;
    padding: 0.85rem;
    border-radius: 6px;
    background: var(--surface2);
    border: 1px solid var(--border);
    overflow-x: auto;
    font-size: 0.78rem;
    line-height: 1.5;
  }
}

@media (max-width: 700px) {
  .ns-layout {
    grid-template-columns: 1fr;
  }
  .run-sidebar {
    position: static;
  }
}

@media (max-width: 920px) {
  .detail-shell {
    .detail-hero {
      grid-template-columns: 1fr;
    }
  }
}

@media (max-width: 640px) {
  .detail-shell {
    .detail-list div {
      grid-template-columns: 1fr;
      gap: 0.2rem;
    }
    .detail-gallery-nav {
      display: none;
    }
  }
}

/* ── Profile form ── */
.profile-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-top: 1.5rem;

  label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.875rem;
  }
  input {
    padding: 0.4em 0.6em;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
  }
}

/* ── Pagination ── */
.pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 1.25rem;
}

/* ── Misc ── */
.muted {
  color: var(--muted);
  font-size: 0.875rem;
}
.mono {
  font-family: monospace;
  font-size: 0.82rem;
}
.error {
  color: var(--danger);
}
h1 {
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
}
h2 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.75rem;
}

/* ── Jobs page ── */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.job-log {
  margin-top: 1rem;
  max-height: 320px;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  font-family: monospace;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-all;
}

.nav-logout {
  display: inline-flex;
}
.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;

  &:hover {
    color: var(--text);
    text-decoration: underline;
  }
}

.navbar {
  flex-wrap: wrap;
}
