﻿:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #647084;
  --line: #dce3ef;
  --blue: #075cff;
  --green: #17a56b;
  --amber: #b77705;
  --red: #d93636;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[hidden] {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.account-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.top-actions,
.picker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.page-nav {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.nav-button {
  min-width: 0;
  padding: 9px 12px;
  background: transparent;
  color: var(--muted);
  border: 0;
}

.nav-button.active {
  background: var(--blue);
  color: #fff;
}

.page {
  display: block;
}

.page:not(.active) {
  display: none;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 20px;
}

.panel,
.stats article,
.export {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.panel-title p {
  color: var(--muted);
  margin-bottom: 0;
}

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

.quick-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.reference-grid {
  grid-template-columns: minmax(280px, 1fr) minmax(160px, 220px) auto;
  align-items: end;
}

.scan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 180px;
  resize: vertical;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 24px;
}

.check input {
  width: 18px;
  height: 18px;
}

.evidence-dir-field {
  grid-column: span 2;
}

.folder-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.folder-picker button {
  white-space: nowrap;
}

.form-status {
  margin: 0;
  align-self: center;
  color: var(--muted);
  font-weight: 700;
}

.product-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  margin-top: 12px;
}

.admin-list,
.logs-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.admin-row,
.log-row {
  display: grid;
  grid-template-columns: 1.2fr 1.5fr 1fr 1fr auto auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.log-row {
  grid-template-columns: 1.2fr 1fr 1fr 2fr;
  color: var(--muted);
}

.product-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.product-row.out-of-stock {
  background: #fff7ed;
  border-color: #fed7aa;
}

.product-row input {
  width: 18px;
  height: 18px;
}

.product-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.product-main strong,
.product-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-main small {
  color: var(--muted);
}

.stock-pill {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.stock-pill.ok {
  background: #e5f7ee;
  color: var(--green);
}

.stock-pill.empty {
  background: #ffedd5;
  color: #c2410c;
}

button,
.export {
  border: 0;
  border-radius: 7px;
  padding: 11px 16px;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  text-align: center;
}

.primary {
  background: var(--blue);
  color: #fff;
  min-width: 150px;
}

.secondary {
  background: #eef3fb;
  color: var(--text);
  border: 1px solid var(--line);
}

.danger {
  background: #fff1f2;
  color: #9f1239;
  border-color: #fecdd3;
}

button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stats article,
.export {
  padding: 16px;
}

.stats span {
  display: block;
  font-size: 30px;
  font-weight: 800;
}

.stats p {
  margin-bottom: 0;
  color: var(--muted);
}

.progress-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin: -4px 0 16px;
}

.progress-head,
.progress-current {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.progress-lines {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 700;
}

.progress-head p,
.progress-error {
  margin: 4px 0 0;
  color: var(--muted);
}

.progress-head span {
  font-weight: 800;
  white-space: nowrap;
}

.progress-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf6;
  margin: 12px 0;
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--blue);
  transition: width 0.25s ease;
}

.progress-current span {
  min-width: 0;
  color: var(--text);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.progress-current a {
  color: var(--blue);
  font-weight: 800;
  white-space: nowrap;
}

.progress-error {
  color: var(--red);
  overflow-wrap: anywhere;
}

.findings {
  display: grid;
  gap: 12px;
}

.similarity-filters {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.similarity-filters strong {
  margin-right: 8px;
}

.similarity-filters span {
  color: var(--muted);
  font-size: 13px;
}

.similarity-filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.similarity-filter {
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.similarity-filter.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.similarity-filter em {
  margin-left: 5px;
  font-style: normal;
  opacity: .75;
}

.finding {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 12px;
  border-left-width: 5px;
}

.finding.group-a {
  background: #ffffff;
  border-left-color: #2563eb;
}

.finding.group-b {
  background: #f8fafc;
  border-left-color: #16a34a;
}

.finding.group-c {
  background: #fff7ed;
  border-left-color: #f97316;
}

.finding.group-d {
  background: #f5f3ff;
  border-left-color: #7c3aed;
}

.finding-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
}

.title {
  font-weight: 800;
  margin-bottom: 4px;
}

.title-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.title-line .title {
  margin-bottom: 0;
}

.thief-summary {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.thief-summary span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.thief-summary span + span::before {
  content: "•";
  color: #94a3b8;
}

.competitor-price {
  color: var(--muted);
}

.competitor-price.higher {
  color: var(--green);
}

.competitor-price.lower {
  color: var(--red);
}

.competitor-price.same {
  color: var(--amber);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
}

.pill {
  border-radius: 999px;
  background: #edf2f7;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 750;
}

.pill.ready {
  background: #e5f7ee;
  color: var(--green);
}

.pill.review {
  background: #fff5df;
  color: var(--amber);
}

.pill.own-price {
  background: #e0f2fe;
  color: #075985;
}

.similarity-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #edf2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.similarity-badge i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: currentColor;
}

.similarity-badge.danger {
  background: #ffe4e6;
  color: #be123c;
}

.similarity-badge.warn {
  background: #fef3c7;
  color: #b45309;
}

.similarity-badge.notice {
  background: #dbeafe;
  color: #1d4ed8;
}

.similarity-badge.low {
  background: #f1f5f9;
  color: #64748b;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.links a {
  color: var(--blue);
  font-weight: 700;
}

.copy-sku {
  padding: 2px 8px;
  min-width: 0;
  border-radius: 6px;
  background: #edf2f7;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.copy-sku.small {
  align-self: center;
  padding: 3px 8px;
  font-size: 12px;
}

.evidence-preview {
  position: fixed;
  z-index: 10000;
  max-width: min(420px, calc(100vw - 28px));
  max-height: min(420px, calc(100vh - 28px));
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.28);
  pointer-events: none;
}

.evidence-preview[hidden] {
  display: none;
}

.evidence-preview img {
  display: block;
  max-width: min(400px, calc(100vw - 46px));
  max-height: min(400px, calc(100vh - 46px));
  object-fit: contain;
  border-radius: 6px;
  background: #f8fafc;
}

.evidence-preview-fallback {
  max-width: 260px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.empty {
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.diagnostics-output {
  display: none;
  margin: 14px 0 0;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  background: #101827;
  color: #e7edf7;
  border-radius: 8px;
  padding: 14px;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.diagnostics-output.visible {
  display: block;
}

@media (max-width: 820px) {
  .topbar,
  .panel-title,
  .finding-head {
    grid-template-columns: 1fr;
    display: grid;
  }

  .grid,
  .quick-form,
  .stats,
  .progress-lines {
    grid-template-columns: 1fr;
  }

  .evidence-dir-field,
  .folder-picker {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .primary {
    width: 100%;
  }

  .top-actions,
  .picker-actions,
  .product-row,
  .admin-row,
  .log-row {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
  }
}

.reference-scan-panel {
  overflow: hidden;
}

.reference-scan-panel > summary {
  cursor: pointer;
  list-style: none;
}

.reference-scan-panel > summary::-webkit-details-marker {
  display: none;
}

.reference-summary {
  align-items: center;
}

.reference-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #d7e2f0;
  border-radius: 7px;
  background: #edf3fb;
  color: #13233d;
  font-weight: 800;
  white-space: nowrap;
}

.reference-scan-panel[open] .reference-toggle::before {
  content: "Свернуть";
}

.reference-scan-panel[open] .reference-toggle {
  font-size: 0;
}

.reference-scan-panel[open] .reference-toggle::before {
  font-size: 14px;
}

.reference-scan-panel .reference-grid {
  margin-top: 14px;
}
