@import url("./theme.css");
@import url("./footer.css");

body {
  background-color: var(--bg-base);
  background-image: radial-gradient(
    ellipse at top,
    #1a1f2e 0%,
    var(--bg-base) 60%
  );
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1 0 auto;
}

[hidden] {
  display: none !important;
}

.auth-buttons {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

#auth,
#registration,
#telegram {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-base);
}

#registration,
#telegram {
  background-color: var(--bg-elevated);
}

#auth:hover,
#registration:hover,
#telegram:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-accent);
  color: var(--text-primary);
  transform: translateY(-1px);
}

#decode-report-button {
  background: var(--accent-gradient);
  color: #fff;
  border: 1px solid transparent;
  padding: 18px 38px;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-base);
  box-shadow: 0 4px 12px rgba(124, 92, 255, 0.3);
}

#decode-report-button:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(124, 92, 255, 0.4);
}

@media (max-width: 600px) {
  .site-header {
    min-height: 52px;
    padding: 0 16px;
  }

  .auth-buttons {
    width: 100%;
    justify-content: center;
  }

  .hero {
    padding: 24px 16px;
  }

  #download-reports-in-zip {
    width: calc(100% - 32px);
    max-width: 320px;
  }

  #download-report-as-xlsx-button {
    width: 100%;
    max-width: 320px;
  }
}

#skus-table {
  margin-top: 40px;
}

#download-report-as-xlsx-button {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  padding: 0 24px;
  min-height: 44px;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-base);
}

#download-report-as-xlsx-button:hover {
  background-color: #217346;
  border-color: #217346;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(33, 115, 70, 0.3);
}

.download-xlsx-wrapper {
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px;
}

.download-xlsx-wrapper:has(#download-report-as-xlsx-button:not([hidden])) {
  margin: 32px auto 24px;
}

/* Кнопка скачивания архива, когда из файлов получилось несколько отчётов */
#download-reports-in-zip {
  display: block;
  margin: 0 auto 24px;
  min-height: 44px;
  padding: 0 32px;
  background: var(--accent-gradient);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-base);
  box-shadow: 0 4px 12px rgba(124, 92, 255, 0.3);
}

#download-reports-in-zip:hover {
  filter: brightness(1.1);
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(124, 92, 255, 0.4);
}

#download-reports-in-zip:active {
  transform: translateY(0);
}

table {
  width: 100%;
  max-width: 1190px;
  margin: 0 auto 24px;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 12.6px 9.8px;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

/* Числовые значения (цены) не должны переноситься на другую строку */
td {
  white-space: nowrap;
}

th {
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-strong);
}

tbody tr {
  transition: background-color var(--transition-fast);
}

tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.02);
}

tbody tr:hover {
  background-color: var(--bg-hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

td:last-child,
th:last-child {
  border-right: none;
}

.report-summary-label-wrapper {
  text-align: center;
  margin: 0 0 12px;
}

.report-summary-label {
  display: inline-block;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-accent);
  padding: 6px 16px;
  background: var(--accent-soft);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-full);
  letter-spacing: 0.35px;
}

#tables-container {
  margin-top: 24px;
  overflow-x: auto;
}

/* ===== Верхняя панель (адаптация .top-bar эталона) ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  min-height: 56px;
  padding: 0 21px;
  background: rgba(22, 27, 34, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

/* ===== Hero-блок ===== */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  padding: 40px 16px 32px;
  max-width: 760px;
  margin: 0 auto;
}

.hero h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.25;
  color: var(--text-primary);
}

.hero .lead {
  margin: 0;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 620px;
}

/* ===== Информационные блоки ===== */
.info-block {
  max-width: 760px;
  margin: 0 auto 32px;
  padding: 0 16px;
}

.info-block h2 {
  margin: 0 0 12px;
  font-size: 22px;
  color: #c4b5fd;
}

.info-block ul,
.info-block ol {
  margin: 0;
  padding-left: 22px;
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 15px;
}

.info-block li + li {
  margin-top: 6px;
}

.info-blocks-row {
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  width: 100%;
  /* 792px = 760px контента hero + его внутренние отступы по 16px */
  max-width: 792px;
  margin: 0 auto 32px;
  padding: 0 16px;
  align-items: flex-start;
  justify-content: center;
}

.info-block {
  flex: 1 1 320px;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 0;
}

#decode-report-button:focus-visible,
#download-report-as-xlsx-button:focus-visible,
#download-reports-in-zip:focus-visible,
#auth:focus-visible,
#registration:focus-visible,
#telegram:focus-visible,
.info-block a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.table-scroll {
  box-sizing: border-box;
  width: 100%;
  max-width: 1190px;
  margin: 0 auto 24px;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  background: var(--bg-surface);
}

/* Радиус, фон и тень задаёт контейнер, иначе они дублируются */
.table-scroll > table {
  width: 100%;
  max-width: none;
  margin: 0;
  overflow: visible;
  border-radius: 0;
  box-shadow: none;
}

/* Заголовки переносятся, чтобы не растягивать таблицу */
.table-scroll > table th {
  overflow-wrap: break-word;
}

/* Артикул — единственное текстовое значение, ему перенос разрешён */
.table-scroll > table th:nth-child(1),
.table-scroll > table td:nth-child(1) {
  white-space: normal;
  overflow-wrap: anywhere;
}

.table-scroll > table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* Артикул */
.table-scroll > table th:nth-child(1),
.table-scroll > table td:nth-child(1) {
  width: 160px;
}

/* Маржинальность % и Итого */
.table-scroll > table th:nth-child(12),
.table-scroll > table td:nth-child(12),
.table-scroll > table th:nth-child(13),
.table-scroll > table td:nth-child(13) {
  width: 110px;
}

/* ============================================================
    Табы переключения годов (адаптация .tabs из эталона)
    ============================================================ */
.tabs {
  position: relative;
  z-index: 10;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: 100%;
  max-width: 1190px;
  margin: 0 auto 12px;
  padding: 0 4px;
  border-bottom: 1px solid var(--border);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab.is-active {
  color: var(--text-accent);
  border-bottom-color: var(--accent);
}
