:root {
  --bg-main: #f2f4f7;
  --bg-soft: #f8f9fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --primary: #111827;
  --primary-hover: #0b1220;
  --success: #1f7a4a;
  --danger: #b42318;
  --shadow-soft: 0 8px 24px rgba(17, 24, 39, 0.08);
  --shadow-modal: 0 20px 46px rgba(17, 24, 39, 0.18);
  --sticky-seller-width: 220px;
  --sticky-topbar-offset: 10px;
  --sticky-table-header-top: 0px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Manrope", "Segoe UI", sans-serif;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #ffffff 0%, var(--bg-main) 46%, #eef1f5 100%),
    repeating-linear-gradient(
      135deg,
      rgba(17, 24, 39, 0.015) 0,
      rgba(17, 24, 39, 0.015) 1px,
      transparent 1px,
      transparent 14px
    );
}

.container {
  width: min(1240px, 94vw);
  margin: 30px auto;
  animation: fade-slide 320ms ease-out;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  position: sticky;
  top: var(--sticky-topbar-offset);
  z-index: 70;
  padding: 10px 12px;
  border: 1px solid rgba(209, 213, 219, 0.65);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.08);
}

h1 {
  margin: 0;
  font-size: clamp(30px, 3.8vw, 42px);
  letter-spacing: -0.03em;
  font-weight: 800;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.actions {
  display: flex;
  gap: 10px;
}

.btn {
  border-radius: 12px;
  padding: 10px 16px;
  min-height: 42px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 700;
  border: 1px solid transparent;
  transition:
    transform 160ms ease,
    box-shadow 200ms ease,
    background-color 200ms ease,
    border-color 200ms ease,
    color 200ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(17, 24, 39, 0.2);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn-secondary:hover {
  background: var(--bg-soft);
}

.status-bar {
  min-height: 24px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.table-hint {
  display: none;
  margin: 0 0 8px;
  color: #6b7280;
  font-size: 12px;
  letter-spacing: 0.01em;
}

.notification-area {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.notification-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #f9fafb;
}

.notification-item--info {
  border-color: #e5e7eb;
  background: #f9fafb;
}

.notification-item--success {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.notification-item--warning {
  border-color: #fde68a;
  background: #fffbeb;
}

.notification-item--error {
  border-color: #fecaca;
  background: #fef2f2;
}

.notification-title {
  font-size: 14px;
  font-weight: 800;
  color: #111827;
}

.notification-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.notification-close {
  width: 24px;
  height: 24px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #6b7280;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.notification-close:hover {
  color: #111827;
  border-color: #9ca3af;
  background: #f9fafb;
}

.notification-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #4b5563;
}

.notification-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: #374151;
}

.notification-list li {
  margin-bottom: 4px;
  font-size: 13px;
}

.status-bar.error {
  color: var(--danger);
}

.status-bar.success {
  color: var(--success);
}

.table-wrap {
  overflow: auto;
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 210px);
  -webkit-overflow-scrolling: touch;
  cursor: grab;
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
}

.table-wrap.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.price-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 980px;
}

.price-table .col-seller {
  width: var(--sticky-seller-width);
}

.price-table .col-product {
  width: 240px;
}

.price-table th,
.price-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid #f0f2f5;
  padding: 13px 12px;
  text-align: left;
  vertical-align: top;
  background: #fff;
}

.price-table th:not(.sticky-col),
.price-table td:not(.sticky-col) {
  min-width: 220px;
}

.price-table td {
  position: relative;
}

.history-cell--active {
  cursor: default;
}

.history-cell--active:hover {
  background: #fff;
}

.price-cell--lowest {
  box-shadow: inset 0 0 0 1px rgba(185, 28, 28, 0.2);
  background: linear-gradient(180deg, #fff 0%, #fff5f5 100%);
}

.price-cell--highest {
  box-shadow: inset 0 0 0 1px rgba(22, 101, 52, 0.2);
  background: linear-gradient(180deg, #fff 0%, #f0fdf4 100%);
}

.price-flag {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fff;
  padding: 3px 8px 3px 10px;
  border-radius: 999px;
  pointer-events: none;
  box-shadow: 0 8px 16px rgba(17, 24, 39, 0.14);
}

.price-flag::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  transform: translate(-45%, -50%);
  background: rgba(255, 255, 255, 0.7);
}

.price-flag--lowest {
  background: linear-gradient(140deg, #ef4444 0%, #b91c1c 100%);
}

.price-flag--highest {
  background: linear-gradient(140deg, #22c55e 0%, #166534 100%);
}

.price-table th {
  background: #f9fafb;
  color: #374151;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
  position: sticky;
  top: var(--sticky-table-header-top);
  z-index: 24;
  box-shadow: inset 0 -1px 0 #e5e7eb;
}

.product-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.product-delete-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid #ef4444;
  border-radius: 6px;
  background: #dc2626;
  color: #ffffff;
  font-size: 14px;
  line-height: 1;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.product-delete-link:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

.price-table tr:last-child td {
  border-bottom: none;
}

.sticky-col {
  position: -webkit-sticky;
  position: sticky;
  left: 0;
  z-index: 10;
  background: #fff;
  background-clip: padding-box;
}

.sticky-col--seller {
  left: 0;
  min-width: var(--sticky-seller-width);
  width: var(--sticky-seller-width);
  z-index: 12;
  box-shadow: 10px 0 14px -12px rgba(17, 24, 39, 0.3);
}

/* Desktop fallback: pirmas stulpelis (seller/domain reikšmė) visada sticky. */
.price-table thead th:first-child,
.price-table tbody td:first-child {
  position: -webkit-sticky;
  position: sticky;
  left: 0;
  background-clip: padding-box;
}

.price-table thead th:first-child {
  z-index: 16;
  background: #f9fafb;
}

.price-table tbody td:first-child {
  z-index: 12;
  background: #fff;
  box-shadow: 10px 0 14px -12px rgba(17, 24, 39, 0.3);
}

.price-table thead .sticky-col {
  background: #f9fafb;
  z-index: 26;
}

.price-table thead .sticky-col--seller {
  z-index: 28;
}

.seller-cell {
  font-weight: 700;
  color: #111827;
}

.table-footer-tools {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.clear-cache-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-style: dashed;
  font-size: 12px;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.price-sale {
  color: #111827;
  font-weight: 800;
  font-size: 16px;
}

.price-old {
  color: #9ca3af;
  text-decoration: line-through;
  margin-top: 2px;
  font-size: 13px;
}

.price-normal {
  color: #111827;
  font-weight: 700;
}

.source-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: #4b5563;
  text-decoration: none;
  border-bottom: 1px solid #d1d5db;
}

.source-link:hover {
  color: #111827;
  border-bottom-color: #9ca3af;
}

.edit-link {
  display: inline-block;
  margin-top: 8px;
  margin-left: 10px;
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.edit-link:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.open-link {
  display: inline-block;
  margin-top: 8px;
  margin-left: 10px;
  padding: 4px 8px;
  border: 1px solid #86efac;
  border-radius: 8px;
  background: #f0fdf4;
  color: #166534;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.open-link:hover {
  background: #dcfce7;
  border-color: #4ade80;
}

.delete-link {
  display: inline-block;
  margin-top: 8px;
  margin-left: 8px;
  padding: 4px 8px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff5f5;
  color: #991b1b;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.delete-link:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

.stat-link {
  display: inline-block;
  margin-top: 8px;
  margin-left: 8px;
  padding: 4px 8px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.stat-link:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.dash {
  color: #9ca3af;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 30px;
  background: #fafafa;
}

.modal {
  border: 1px solid var(--line);
  border-radius: 16px;
  width: min(580px, 92vw);
  max-height: 92vh;
  overflow: hidden;
  padding: 0;
  box-shadow: var(--shadow-modal);
}

.modal::backdrop {
  background: rgba(17, 24, 39, 0.4);
}

.modal-content {
  display: grid;
  gap: 10px;
  padding: 18px;
  background: #fff;
  max-height: 88vh;
  overflow: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.close-btn {
  border: 1px solid transparent;
  background: #fff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: #6b7280;
}

.close-btn:hover {
  border-color: var(--line);
  background: #f9fafb;
  color: #374151;
}

label {
  font-size: 12px;
  color: #4b5563;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 700;
  color: #374151;
}

.check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

input,
textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  padding: 10px 12px;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 130px;
  resize: vertical;
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  line-height: 1.4;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: #9ca3af;
  box-shadow: 0 0 0 4px rgba(156, 163, 175, 0.18);
}

.suggestions {
  margin-top: -6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.suggestion-item {
  width: 100%;
  border: none;
  border-bottom: 1px solid #f3f4f6;
  padding: 10px 11px;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  background: #fff;
  color: var(--ink);
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background: #f8fafc;
}

.field-notice {
  min-height: 18px;
  margin-top: -4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #64748b;
}

.field-notice--info {
  color: #1d4ed8;
}

.field-notice--success {
  color: #166534;
}

.field-notice--error {
  color: #b91c1c;
}

.selector-suggestions {
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fafb;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.selector-suggestions[hidden] {
  display: none;
}

.selector-suggestions-head {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4b5563;
  font-weight: 800;
}

.price-search-box {
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fafb;
  padding: 10px;
  display: grid;
  gap: 10px;
}

.price-search-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.price-search-box .btn {
  width: 100%;
}

.selector-suggestion-list {
  display: grid;
  gap: 8px;
}

.selector-suggestion-item {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  padding: 10px;
}

.selector-suggestion-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.selector-suggestion-title {
  font-size: 13px;
  font-weight: 800;
  color: #111827;
}

.selector-suggestion-source {
  font-size: 11px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.selector-suggestion-prices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.selector-suggestion-price {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  padding: 7px 9px;
}

.selector-suggestion-price-label {
  font-size: 10px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.selector-suggestion-price-value {
  margin-top: 3px;
  font-size: 15px;
  font-weight: 800;
  color: #111827;
}

.selector-suggestion-selectors {
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 8px;
  line-height: 1.4;
  word-break: break-all;
}

.selector-suggestion-choose {
  width: 100%;
  min-height: 36px;
}

.selector-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px dashed #d1d5db;
  border-radius: 10px;
  background: #ffffff;
  color: #374151;
  font-size: 12px;
  font-weight: 700;
}

.selector-loading[hidden] {
  display: none;
}

.spinner {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.spinner::before {
  content: "⌛";
  display: inline-block;
  font-size: 14px;
  line-height: 1;
  animation: spin 900ms linear infinite;
}

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

.preview-card {
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fafb;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.preview-head h3 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.01em;
  color: #111827;
}

.preview-check-btn {
  padding: 7px 10px;
  font-size: 12px;
}

.preview-status {
  font-size: 13px;
  color: #4b5563;
}

.preview-status.error {
  color: #991b1b;
}

.preview-status.success {
  color: #065f46;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.preview-item {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
}

.preview-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin-bottom: 3px;
}

.preview-value {
  font-size: 16px;
  font-weight: 800;
  color: #111827;
}

.history-modal {
  width: min(900px, 96vw);
}

.history-modal-content {
  gap: 14px;
}

.history-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.history-stat-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #f9fafb;
}

.history-stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

.history-stat-value {
  font-size: 21px;
  font-weight: 800;
  color: #111827;
}

.history-stat-date {
  margin-top: 4px;
  font-size: 12px;
  color: #6b7280;
}

.history-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 660px;
}

.history-table th,
.history-table td {
  border-bottom: 1px solid #eef2f7;
  padding: 10px 12px;
  font-size: 14px;
}

.history-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4b5563;
  background: #f9fafb;
}

.history-table tr:last-child td {
  border-bottom: none;
}

@keyframes fade-slide {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 720px) {
  :root {
    --sticky-seller-width: 168px;
    --sticky-topbar-offset: 6px;
    --sticky-table-header-top: 0px;
  }

  .container {
    width: 100%;
    margin: 14px 0;
    padding: 0 10px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 10px;
  }

  .actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .actions .btn {
    width: 100%;
  }

  .table-hint {
    display: block;
  }

  .price-table th,
  .price-table td {
    padding: 11px 10px;
    font-size: 13px;
  }

  .price-table {
    min-width: 760px;
  }

  .price-table .col-product {
    width: 190px;
  }

  .price-table th,
  .price-table td {
    min-width: 170px;
  }

  .price-table .sticky-col {
    position: -webkit-sticky;
    position: sticky;
    z-index: 8;
  }

  .price-table .sticky-col--seller {
    left: 0;
    z-index: 10;
  }

  .price-table thead .sticky-col {
    z-index: 12;
  }

  .table-wrap {
    max-height: calc(100vh - 245px);
  }

  .seller-cell {
    white-space: nowrap;
  }

  .source-link,
  .open-link,
  .edit-link,
  .delete-link,
  .stat-link {
    min-height: 34px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .table-footer-tools {
    margin-top: 8px;
  }

  .clear-cache-btn {
    width: 100%;
  }

  .history-stats {
    grid-template-columns: 1fr;
  }

  .preview-grid {
    grid-template-columns: 1fr;
  }

  .price-search-grid {
    grid-template-columns: 1fr;
  }

  .modal {
    width: 100vw;
    max-width: 100vw;
    border-radius: 16px 16px 0 0;
    margin: 0;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
  }

  .modal-content {
    max-height: 84vh;
    padding: 14px;
  }

  input,
  textarea {
    font-size: 16px;
  }
}
