*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3345;
  --text: #e1e4ed;
  --text-muted: #8b90a5;
  --primary: #6c8cff;
  --primary-hover: #8ba3ff;
  --green: #34d399;
  --blue: #60a5fa;
  --red: #f87171;
  --yellow: #fbbf24;
  --gray: #6b7280;
  --radius: 8px;
  --radius-sm: 4px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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

.hidden { display: none !important; }

/* Login */
.login-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 400px;
}
.login-card h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.login-card p { color: var(--text-muted); margin-bottom: 1.5rem; }
.login-card label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.25rem; margin-top: 0.75rem; }
.login-card input { width: 100%; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.logo { font-weight: 700; font-size: 1.1rem; color: var(--text); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.5rem 1rem; border: none; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500; cursor: pointer; transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

/* Inputs */
input, select, textarea {
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.45rem 0.6rem; font-size: 0.875rem;
  width: 100%; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }

/* Layout */
.container {
  display: flex; gap: 1.5rem; padding: 1.5rem;
  max-width: 1600px; margin: 0 auto;
}

/* Filters */
.filters {
  width: 240px; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  height: fit-content; position: sticky; top: 4rem;
}
.filters h2 { font-size: 1rem; margin-bottom: 0.75rem; }
.filters label { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 0.6rem; margin-bottom: 0.2rem; }
.filters input, .filters select { font-size: 0.8rem; padding: 0.35rem 0.5rem; }
.filter-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
.filter-actions .btn { flex: 1; }

/* Content */
.content { flex: 1; min-width: 0; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.result-count { font-size: 0.85rem; color: var(--text-muted); }
#toggle-filters { display: none; }

/* Table */
.offers-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.offers-table th {
  text-align: left; padding: 0.6rem 0.75rem; font-weight: 600; font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.offers-table td {
  padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.offers-table tbody tr { cursor: pointer; transition: background 0.1s; }
.offers-table tbody tr:hover { background: var(--surface2); }
.offers-table .title-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offers-table .num-cell { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

#offers-table-wrap { overflow-x: auto; }

/* Badges */
.badge {
  display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px;
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-active { background: rgba(52,211,153,0.15); color: var(--green); }
.badge-interesting { background: rgba(96,165,250,0.15); color: var(--blue); }
.badge-rejected { background: rgba(248,113,113,0.15); color: var(--red); }
.badge-archived { background: rgba(107,114,128,0.15); color: var(--gray); }
.badge-deleted { background: rgba(107,114,128,0.1); color: var(--gray); text-decoration: line-through; }
.badge-otodom { background: rgba(96,165,250,0.12); color: var(--blue); }
.badge-tui { background: rgba(251,191,36,0.15); color: var(--yellow); }

/* Rating stars */
.stars { display: inline-flex; gap: 2px; }
.star {
  cursor: pointer; font-size: 1rem; color: var(--border);
  transition: color 0.1s; user-select: none; background: none; border: none; padding: 0;
}
.star.filled { color: var(--yellow); }
.star:hover { color: var(--yellow); }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-top: 1rem; }
.pagination .btn { min-width: 2.2rem; }
.page-info { font-size: 0.8rem; color: var(--text-muted); }

/* Loading / empty */
.loading, .empty { text-align: center; padding: 3rem; color: var(--text-muted); font-size: 0.9rem; }

/* Detail page */
.detail-layout { display: block; max-width: 960px; }
.detail-header { margin-bottom: 1.5rem; }
.detail-header-main h1 { font-size: 1.4rem; margin-bottom: 0.5rem; }
.detail-meta { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.detail-actions { display: flex; align-items: center; gap: 1rem; margin-top: 0.75rem; }
.status-select { width: auto; min-width: 130px; }

.detail-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.detail-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.75rem 1rem;
}
.detail-card h3 { font-size: 0.7rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.04em; margin-bottom: 0.25rem; }
.detail-value { font-size: 1.1rem; font-weight: 600; }
.detail-sub { font-size: 0.8rem; color: var(--text-muted); }

.detail-section { margin-bottom: 1.5rem; }
.detail-section h3 { font-size: 0.9rem; margin-bottom: 0.75rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border); }

.notes-textarea { resize: vertical; min-height: 60px; margin-bottom: 0.5rem; }

/* Image gallery */
.image-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.5rem; }
.image-gallery img {
  width: 100%; height: 120px; object-fit: cover; border-radius: var(--radius-sm);
  cursor: pointer; border: 1px solid var(--border); transition: opacity 0.15s;
}
.image-gallery img:hover { opacity: 0.8; }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
}
.lightbox-img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: var(--radius); }
.lightbox-close, .lightbox-prev, .lightbox-next {
  position: absolute; background: none; border: none; color: #fff;
  font-size: 2rem; cursor: pointer; padding: 0.5rem; opacity: 0.7; z-index: 201;
}
.lightbox-close:hover, .lightbox-prev:hover, .lightbox-next:hover { opacity: 1; }
.lightbox-close { top: 1rem; right: 1.5rem; font-size: 2.5rem; }
.lightbox-prev { left: 1rem; top: 50%; transform: translateY(-50%); font-size: 3rem; }
.lightbox-next { right: 1rem; top: 50%; transform: translateY(-50%); font-size: 3rem; }

/* Snapshots table */
.snapshots-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.snapshots-table th {
  text-align: left; padding: 0.5rem 0.6rem; font-weight: 600; font-size: 0.75rem;
  text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.snapshots-table td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }

/* Meta list */
.meta-list { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; font-size: 0.85rem; }
.meta-list dt { color: var(--text-muted); font-weight: 500; }
.meta-list dd { word-break: break-all; }

/* Responsive */
@media (max-width: 768px) {
  .container { flex-direction: column; padding: 1rem; }
  .filters { width: 100%; position: static; }
  .filters.collapsed { display: none; }
  #toggle-filters { display: inline-flex; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .image-gallery { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}
