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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: #1a1a2e;
  background: #f4f6f9;
  min-height: 100vh;
}

/* Navbar */
.navbar {
  background: #1a1a2e;
  color: #fff;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 52px;
}
.nav-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}
.nav-links { display: flex; gap: 1.2rem; }
.nav-links a {
  color: #a0aec0;
  text-decoration: none;
  font-size: 0.9rem;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav-links a:hover { color: #fff; border-bottom-color: #4299e1; }

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

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s, opacity 0.15s;
  line-height: 1.4;
}
.btn-primary { background: #3182ce; color: #fff; }
.btn-primary:hover { background: #2b6cb0; }
.btn-secondary { background: #e2e8f0; color: #2d3748; }
.btn-secondary:hover { background: #cbd5e0; }
.btn-danger { background: #e53e3e; color: #fff; }
.btn-danger:hover { background: #c53030; }
.btn-success { background: #38a169; color: #fff; }
.btn-success:hover { background: #2f855a; }
.btn-success-outline { background: #fff; color: #38a169; border: 1px solid #38a169; }
.btn-success-outline:hover { background: #f0fff4; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.78rem; }

/* Search form */
.search-header { margin-bottom: 1.2rem; }
.search-header h1 { font-size: 1.3rem; color: #1a1a2e; margin-bottom: 0.4rem; }
.meta-info { font-size: 0.82rem; color: #718096; }
.meta-info.warn { color: #c05621; background: #fffaf0; padding: 0.5rem; border-radius: 4px; border-left: 3px solid #ed8936; }

.search-form { background: #fff; border-radius: 10px; padding: 1.2rem 1.5rem; margin-bottom: 1.2rem; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.search-fields { display: flex; gap: 0.8rem; align-items: flex-end; flex-wrap: wrap; }
.field-group { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; min-width: 160px; }
.field-group label { font-size: 0.78rem; font-weight: 600; color: #4a5568; text-transform: uppercase; letter-spacing: 0.04em; }
.field-group input[type=text] {
  padding: 0.5rem 0.75rem;
  border: 1.5px solid #cbd5e0;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: border-color 0.15s;
  width: 100%;
}
.field-group input[type=text]:focus { outline: none; border-color: #3182ce; box-shadow: 0 0 0 2px rgba(49,130,206,0.15); }
.search-hint { font-size: 0.78rem; color: #a0aec0; margin-top: 0.6rem; }
.hint { color: #a0aec0; font-weight: 400; }

/* Results */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
  color: #4a5568;
  font-size: 0.9rem;
}
.results-header strong { color: #1a1a2e; }
.pagination-info { color: #718096; font-size: 0.82rem; }

.table-wrap { overflow-x: auto; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.results-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 0.85rem;
}
.results-table th {
  background: #f7fafc;
  padding: 0.65rem 0.85rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: #4a5568;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}
.results-table td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid #edf2f7;
  vertical-align: top;
}
.results-table tr:last-child td { border-bottom: none; }
.results-table tbody tr:hover { background: #f7fafc; }
.row-blacklisted { opacity: 0.5; }
.row-whitelisted { opacity: 0.55; background: #f0fff4; }

.org-cell { min-width: 200px; max-width: 280px; }
.org-name { font-weight: 500; line-height: 1.3; }
.org-inn { color: #718096; font-size: 0.78rem; margin-top: 2px; }

/* Org column moved to the right — smaller font */
.org-col-header { font-size: 0.68rem !important; color: #a0aec0 !important; }
.org-cell-right { min-width: 130px; max-width: 190px; font-size: 0.72rem; color: #718096; }
.org-name-sm { font-weight: 500; line-height: 1.3; color: #4a5568; font-size: 0.72rem; }
.org-inn-sm { color: #a0aec0; font-size: 0.68rem; margin-top: 1px; }

.product-name { min-width: 250px; max-width: 420px; line-height: 1.4; }
.score-cell { white-space: nowrap; font-family: monospace; font-size: 0.82rem; color: #4a5568; text-align: right; }
.code-cell { white-space: nowrap; font-family: monospace; font-size: 0.82rem; color: #4a5568; }
.date-cell { white-space: nowrap; font-size: 0.82rem; }
.date-cell.expired { color: #c53030; }
.date-cell.expires-soon { color: #c53030; font-weight: 600; }

/* Exception row highlight in preview-blacklist */
.row-exception { background: #f0fff4 !important; }
.hint-text { font-size: 0.82rem; color: #718096; align-self: center; margin-left: 0.5rem; }
.link-cell { white-space: nowrap; }
.link-card { font-size: 1rem; text-decoration: none; color: #3182ce; margin-right: 4px; }
.link-doc { text-decoration: none; }
.action-cell { white-space: nowrap; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
  color: #4a5568;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #718096;
}
.empty-state p { margin-bottom: 0.5rem; }

/* Admin */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.2rem;
  margin-top: 1rem;
}
.admin-card {
  background: #fff;
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.admin-card h3 { font-size: 1rem; margin-bottom: 1rem; color: #1a1a2e; }
.admin-card dl { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1rem; font-size: 0.88rem; }
.admin-card dt { color: #718096; font-weight: 500; }
.admin-card dd { color: #1a1a2e; }
.admin-card pre { background: #f7fafc; padding: 0.5rem 0.75rem; border-radius: 5px; font-size: 0.82rem; margin: 0.5rem 0; overflow-x: auto; }
.admin-card textarea { width: 100%; padding: 0.5rem; border: 1.5px solid #cbd5e0; border-radius: 6px; font-family: monospace; font-size: 0.85rem; margin-bottom: 0.8rem; resize: vertical; }
.admin-links { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; }

/* Preview blacklist page */
.preview-header { background: #fff; border-radius: 10px; padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.preview-header h2 { margin-bottom: 1rem; }
.org-card { background: #f7fafc; border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.org-name-big { font-size: 1.1rem; font-weight: 600; }
.org-inn-big { color: #718096; font-family: monospace; margin-top: 2px; }
.org-count { margin-top: 4px; color: #4a5568; font-size: 0.9rem; }
.preview-header form { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-top: 0.5rem; }
.confirm-bottom { background: #fff; border-radius: 10px; padding: 1.2rem 1.5rem; margin-top: 1.5rem; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.confirm-bottom form { display: flex; gap: 0.8rem; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.88rem; }
.alert-info { background: #ebf8ff; color: #2b6cb0; border-left: 3px solid #3182ce; }
.alert-warn { background: #fffaf0; color: #c05621; border-left: 3px solid #ed8936; }

/* Page header */
.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem; }
.page-header h1 { font-size: 1.3rem; }
.badge { display: inline-block; background: #e2e8f0; color: #4a5568; padding: 0.2rem 0.65rem; border-radius: 20px; font-size: 0.8rem; font-weight: 600; }
.badge-danger { background: #fed7d7; color: #c53030; }
.badge-success { background: #c6f6d5; color: #276749; }

/* Bulk actions */
.bulk-actions { display: flex; gap: 0.8rem; margin-bottom: 1rem; }
.checkbox-label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.88rem; cursor: pointer; padding: 0.45rem 0; }

/* Registry number link */
.reg-link { color: #3182ce; text-decoration: underline; cursor: pointer; font-family: monospace; font-size: 0.82rem; }
.reg-link:hover { color: #2b6cb0; }

/* ═══ Product detail modal ═══ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  max-width: 1200px;
  width: 100%;
  max-height: 93vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-close {
  position: sticky;
  top: 0.75rem;
  float: right;
  margin: 0.75rem 0.75rem 0 0;
  background: #e2e8f0;
  border: none;
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  z-index: 10;
  color: #4a5568;
}
.modal-close:hover { background: #cbd5e0; }
.modal-loading { padding: 3rem; text-align: center; color: #718096; font-size: 1rem; }
.modal-error { padding: 2rem; color: #c53030; text-align: center; }
.modal-no-card { color: #718096; padding: 1rem 0; }
.modal-inner {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 0;
  padding: 1.5rem;
  padding-top: 0.5rem;
}
@media (max-width: 680px) {
  .modal-inner { grid-template-columns: 1fr; }
}

/* Photo gallery */
.photo-gallery { padding-right: 1.5rem; }
.photo-main {
  background: #f7fafc;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.6rem;
}
.photo-main img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
}
.photo-thumbs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.photo-thumb {
  width: 56px; height: 56px;
  object-fit: cover;
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s;
  background: #f7fafc;
}
.photo-thumb:hover { border-color: #3182ce; }
.photo-thumb.active { border-color: #3182ce; }

/* Info block */
.modal-info { min-width: 0; }
.modal-title { font-size: 1rem; font-weight: 600; line-height: 1.4; margin-bottom: 0.8rem; color: #1a1a2e; }
.modal-price { font-size: 1.3rem; font-weight: 700; color: #276749; margin-bottom: 0.8rem; }
.modal-desc {
  font-size: 0.85rem;
  color: #4a5568;
  line-height: 1.6;
  margin-bottom: 1rem;
  max-height: 280px;
  overflow-y: auto;
  border-left: 3px solid #e2e8f0;
  padding-left: 0.75rem;
}

.modal-chars-wrap {
  max-height: 380px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

/* Characteristics table */
.modal-chars {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-bottom: 1rem;
}
.modal-chars th {
  background: #f7fafc;
  padding: 0.4rem 0.6rem;
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #718096;
  border-bottom: 2px solid #e2e8f0;
}
.modal-chars td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid #edf2f7;
  vertical-align: top;
}
.modal-chars tr:last-child td { border-bottom: none; }
.modal-chars td:first-child { color: #718096; width: 45%; }
.modal-chars td:last-child { font-weight: 500; }

.modal-gisp-link { margin-top: 0.5rem; display: inline-block; }

/* ═══ Filters & sort ═══ */
.filter-row {
  display: flex;
  gap: 0.8rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid #e2e8f0;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.filter-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #4a5568;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.filter-group input[type=text],
.filter-group input[type=date],
.filter-group select {
  padding: 0.45rem 0.65rem;
  border: 1.5px solid #cbd5e0;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
  color: #1a1a2e;
  height: 36px;
}
.filter-group input[type=text]:focus,
.filter-group input[type=date]:focus,
.filter-group select:focus {
  outline: none;
  border-color: #3182ce;
  box-shadow: 0 0 0 2px rgba(49,130,206,0.15);
}
.sort-group select { cursor: pointer; min-width: 180px; }
.date-range { display: flex; align-items: center; gap: 0.3rem; }
.date-range input[type=date] { flex: 1; min-width: 0; }
.date-sep { color: #a0aec0; font-size: 0.9rem; flex-shrink: 0; }

.filter-checks {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  padding-bottom: 2px;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.83rem;
  color: #4a5568;
  cursor: pointer;
  white-space: nowrap;
  padding: 0.45rem 0.7rem;
  border: 1.5px solid #cbd5e0;
  border-radius: 6px;
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
  height: 36px;
}
.check-label:hover { border-color: #a0aec0; background: #f7fafc; }
.check-label input[type=checkbox] { cursor: pointer; accent-color: #3182ce; }
.check-label:has(input:checked) {
  border-color: #3182ce;
  background: #ebf8ff;
  color: #2b6cb0;
  font-weight: 500;
}

/* Active filters indicator */
.filter-active-badge {
  display: inline-block;
  background: #ebf8ff;
  color: #2b6cb0;
  border: 1px solid #bee3f8;
  padding: 0.1rem 0.55rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-left: 0.5rem;
}

/* Product flag badges */
.flag-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}
.flag-ai  { background: #e9d8fd; color: #553c9a; }
.flag-ht  { background: #c6f6d5; color: #276749; }
.flag-pak { background: #feebc8; color: #7b341e; }

/* Row thumbnail */
.photo-cell {
  width: 64px;
  min-width: 56px;
  padding: 0.35rem 0.5rem !important;
  vertical-align: middle !important;
}
.row-thumb {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.row-thumb:empty {
  display: none;
}
.row-thumb-img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  border: 1.5px solid #e2e8f0;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #f7fafc;
}
.row-thumb-img:hover {
  border-color: #3182ce;
  box-shadow: 0 2px 8px rgba(49,130,206,0.25);
}
