@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap");

:root {
  --bg: #060d18;
  --bg-soft: #0c1424;
  --panel: rgba(12, 20, 36, 0.85);
  --panel-border: rgba(255, 255, 255, 0.06);
  --text: #f0f4fa;
  --muted: #7b8fa8;
  --accent: #5b9cf5;
  --accent-soft: rgba(91, 156, 245, 0.15);
  --success: #34d399;
  --warning: #fbbf24;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
  --radius: 20px;
  --radius-sm: 12px;
  --transition: 0.2s ease;
}

html[data-theme="light"] {
  --bg: #ffffff;
  --bg-soft: #f5f5f7;
  --panel: #ffffff;
  --panel-border: rgba(0, 0, 0, 0.08);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, 0.12);
  --success: #34c759;
  --warning: #ff9500;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --radius: 24px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", sans-serif;
  background: radial-gradient(ellipse 80% 50% at 0% 0%, rgba(59, 130, 246, 0.18), transparent 50%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(16, 185, 129, 0.08), transparent 45%),
    linear-gradient(180deg, #060d18 0%, #0a1322 50%, #080f1a 100%);
  color: var(--text);
  min-height: 100vh;
}

html[data-theme="light"] body {
  background: linear-gradient(180deg, #ffffff 0%, #f5f5f7 50%, #ebebed 100%);
  color: var(--text);
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 28px 22px;
  border-right: 1px solid var(--panel-border);
  background: rgba(6, 13, 24, 0.82);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
}

html[data-theme="light"] .sidebar {
  background: rgba(255, 255, 255, 0.9);
  border-right-color: rgba(0, 0, 0, 0.08);
}

.logo {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 36px;
  cursor: pointer;
  transition: var(--transition);
  border-radius: var(--radius-sm);
  padding: 4px 0;
}

.logo:hover {
  opacity: 0.9;
}

.logo-badge {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  background: linear-gradient(135deg, #4ea1ff, #6bffcf);
  color: #081122;
  overflow: hidden;
}

.logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.logo h2 {
  margin: 0;
  font-size: 18px;
}

.logo p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-link {
  color: #b8c9e8;
  text-decoration: none;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

html[data-theme="light"] .menu-link {
  color: #1d1d1f;
}

.menu-link:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.menu-link.active {
  background: linear-gradient(135deg, rgba(91, 156, 245, 0.2), rgba(52, 211, 153, 0.1));
  color: #fff;
  font-weight: 600;
}

html[data-theme="light"] .menu-link.active {
  background: rgba(0, 122, 255, 0.15);
  color: #007aff;
}

.main {
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.1;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  padding: 22px;
  margin-bottom: 24px;
}

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

.panel-head h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.upload-grid {
  display: grid;
  gap: 12px;
}

.upload-field span.upload-label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--muted);
}

.upload-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.feed-url-box {
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2, rgba(255, 255, 255, 0.03));
}

.feed-url-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.feed-url-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.feed-url-input {
  flex: 1 1 280px;
  min-width: 200px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}

.date-input {
  width: 100%;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: #c8d7f2;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  color-scheme: dark;
}

html[data-theme="light"] .date-input {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
  color-scheme: light;
}

.date-input::file-selector-button {
  margin-right: 12px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  padding: 8px 12px;
  color: #c8d7f2;
  cursor: pointer;
  transition: var(--transition);
}

html[data-theme="light"] .date-input::file-selector-button {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

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

/* ReportHub-specific: make file input look like CRM inputs */
.date-input[type="file"] {
  padding: 10px 12px;
}

.filter-btn {
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: #c8d7f2;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

html[data-theme="light"] .filter-btn {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
  border-color: rgba(0, 0, 0, 0.1);
}

.filter-btn:hover {
  background: var(--accent-soft);
  border-color: rgba(91, 156, 245, 0.25);
}

.filter-btn.active {
  background: linear-gradient(135deg, rgba(91, 156, 245, 0.22), rgba(52, 211, 153, 0.12));
  border-color: rgba(91, 156, 245, 0.4);
  color: #fff;
  font-weight: 600;
}

html[data-theme="light"] .filter-btn.active {
  background: rgba(0, 122, 255, 0.18);
  border-color: rgba(0, 122, 255, 0.4);
  color: #007aff;
}

.spinner {
  display: none;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: rgba(255, 255, 255, 0.85);
  animation: spin 850ms linear infinite;
}

.filter-btn.is-loading .spinner {
  display: inline-block;
}

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

.avito-flow-hint {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.45;
}

.avito-flow-block {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: var(--bg-soft);
}

.avito-flow-block h4 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
}

.avito-flow-block .avito-flow-block-desc {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.avito-flow-or {
  margin: 18px 0 0;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

.avito-sheet-select {
  max-width: 32rem;
  min-height: 8.5rem;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.35;
}

html[data-theme="light"] .avito-sheet-select {
  background: #fff;
}

.status {
  margin-top: 10px;
  min-height: 22px;
  font-size: 13px;
}

.status.error {
  color: #fca5a5;
}

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

.results {
  margin-top: 12px;
}

.results-title {
  font-weight: 700;
  font-size: 16px;
  margin: 10px 0 12px;
}

.results-cities {
  display: grid;
  gap: 12px;
}

.results-city-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin: 6px 0 8px;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.tab-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tab-bar-secondary {
  margin-top: 10px;
}

.download-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.results-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.vk-filters-details {
  margin-top: 10px;
}

.vk-filters-details summary {
  list-style: none;
  display: inline-flex;
}

.vk-filters-details summary::-webkit-details-marker {
  display: none;
}

.vk-filters-body {
  margin-top: 10px;
}

.table-wrap {
  margin-top: 12px;
  overflow-x: auto;
}

.city-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  table-layout: auto;
}

.city-table th,
.city-table td {
  border-bottom: 1px solid var(--panel-border);
  padding: 10px 8px;
  text-align: left;
  vertical-align: middle;
}

.city-table th {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}

.city-table td {
  font-size: 14px;
  min-height: 72px;
}

.city-table th:first-child,
.city-table td:first-child {
  width: 34%;
  word-break: break-word;
}

.city-table th:nth-child(2),
.city-table td:nth-child(2) {
  width: 10%;
  white-space: nowrap;
}

.city-table th:nth-child(3),
.city-table td:nth-child(3) {
  width: 32%;
}

.city-table th:nth-child(4),
.city-table td:nth-child(4) {
  width: 26%;
  text-align: left;
  white-space: nowrap;
}

.avito-changes {
  margin-top: 14px;
}

.price-changes-block {
  margin-top: 12px;
}

.price-changes-block:first-child {
  margin-top: 0;
}

.avito-changes-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.avito-changes .table-wrap {
  margin-top: 0;
  max-height: 360px;
  overflow-y: auto;
}

.avito-changes-note {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.avito-price-diff-table {
  min-width: 720px;
}

.avito-price-diff-table th:nth-child(1),
.avito-price-diff-table td:nth-child(1) {
  width: 9%;
  white-space: nowrap;
}

.avito-price-diff-table th:nth-child(2),
.avito-price-diff-table td:nth-child(2) {
  width: 32%;
  word-break: break-word;
}

.avito-price-diff-table th:nth-child(3),
.avito-price-diff-table td:nth-child(3) {
  width: 28%;
  word-break: break-word;
}

.avito-price-diff-table th:nth-child(4),
.avito-price-diff-table td:nth-child(4),
.avito-price-diff-table th:nth-child(5),
.avito-price-diff-table td:nth-child(5) {
  width: 12%;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}

.row-actions .filter-btn {
  padding: 8px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.product-thumb {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--panel-border);
  cursor: zoom-in;
}

.product-gallery {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  padding-top: 6px;
  padding-bottom: 2px;
}

.product-thumb-wrap {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.thumb-remove-btn {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.95);
  color: #fff;
  line-height: 1;
  font-size: 12px;
  cursor: pointer;
}

.image-preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.image-preview-modal[hidden] {
  display: none !important;
}

.image-preview-modal__content {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.image-preview-modal__close {
  position: absolute;
  top: 14px;
  right: 18px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.image-preview-modal__img {
  max-width: min(92vw, 1000px);
  max-height: 88vh;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 880px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  .main {
    padding: 18px;
  }
}

