/* ── Design tokens ──────────────────────────────────────────────────────── */
:root {
  /* Colors */
  --black: #111111;
  --grey-5: #888888;
  --grey-4: #999999;
  --grey-3: #E0E0E0;
  --grey-2: #F2F2F2;
  --grey-1: #F5F5F5;
  --white: #FFFFFF;

  --blue: #2284F6;
  --blue-sec: #EEF2FE;
  --blue-fade: #4F95FF;

  --green: #1CAA6C;
  --green-sec: #F2FFF9;

  --yellow: #FCA238;
  --yellow-sec: #FFF8EB;

  --red: #DC2800;
  --red-sec: #FFF3F0;

  /* Spacing (4px grid) */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --s10: 40px;
  --s12: 48px;
  --s14: 56px;

  /* Radius */
  --r2: 8px;
  --r3: 12px;
  --r4: 16px;

  /* Shadows */
  --shadow-1: 0 2px 16px 0 rgba(17,17,17,.05);
  --shadow-1-hover: 0 4px 16px 0 rgba(17,17,17,.10);

  /* Extended palette */
  --black-fade: #414141;

  /* Typography */
  --font: 'Inter', system-ui, sans-serif;
  --transition: 125ms ease-in-out;
}

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

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  color: var(--black);
  background: var(--grey-1);
  min-height: 100vh;
  padding: var(--s14) 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
}

#upload-view {
  min-height: calc(100vh - 2 * var(--s14));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#upload-view[hidden],
#report-view[hidden] {
  display: none;
}

/* ── Upload zone ─────────────────────────────────────────────────────────── */
.drop-zone {
  background: var(--white);
  border: 1px solid var(--grey-1);
  border-radius: 24px;
  padding: var(--s12) var(--s8);
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--transition);
  text-align: center;
  user-select: none;
}

.drop-zone:hover,
.drop-zone.dragover {
  box-shadow: var(--shadow-1-hover);
}

.drop-zone:hover .drop-label {
  color: var(--black-fade);
}

.drop-zone:hover .drop-icon-wrap {
  color: var(--black);
}

.drop-zone.loading {
  pointer-events: none;
  opacity: .7;
}

.drop-icon-wrap {
  padding: var(--s4);
  border-radius: var(--r3);
  background: var(--grey-1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--grey-5);
  flex-shrink: 0;
  margin-bottom: var(--s4);
  transition: color var(--transition);
}

.drop-label {
  font-size: 18px;
  line-height: 22px;
  font-weight: 600;
  color: var(--black);
  margin-bottom: var(--s2);
  transition: color var(--transition);
}

.drop-hint {
  font-size: 12px;
  line-height: 16px;
  font-weight: 400;
  color: var(--grey-5);
}

.upload-error {
  margin-top: var(--s3);
  padding: var(--s2) var(--s4);
  background: var(--red-sec);
  border-radius: var(--r2);
  color: var(--red);
  font-size: 13px;
}

/* ── Report ──────────────────────────────────────────────────────────────── */
#report-view {
  display: flex;
  flex-direction: column;
  gap: var(--s6);
}

.report-filename {
  font-size: 32px;
  font-weight: 700;
  line-height: 40px;
  color: var(--black);
}

.report-block {
  background: var(--white);
  border: 1px solid var(--grey-1);
  border-radius: 24px;
  box-shadow: var(--shadow-1);
  padding: var(--s6);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

/* ── Check rows (header block) ─────────────────────────────────────────── */
.check-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 14px;
  font-weight: 600;
  line-height: 18px;
}

.check-row.ok   { color: var(--green); }
.check-row.error { color: var(--red); }
.check-row.warn  { color: var(--yellow); }

.check-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

/* ── Check details (mini-плашки ошибок структуры) ───────────────────────── */
.check-details {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.check-detail {
  padding: var(--s4);
  border-radius: var(--r4);
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

.check-detail-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 18px;
}

.check-detail-body {
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
}

.check-detail.error { background: var(--red-sec); }
.check-detail.error .check-detail-title { color: var(--red); }
.check-detail.error .check-detail-body  { color: var(--black); }

.check-detail.warn { background: var(--yellow-sec); }
.check-detail.warn .check-detail-title { color: #8a5200; }
.check-detail.warn .check-detail-body  { color: var(--black); }

/* ── Issue table ─────────────────────────────────────────────────────────── */
.issue-table {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.issue-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr);
  gap: var(--s4);
  padding: var(--s4);
  border-radius: var(--r4);
  font-size: 14px;
  line-height: 18px;
  align-items: start;
}

.issue-row-error {
  background: var(--red-sec);
}

.issue-row-warn {
  background: var(--yellow-sec);
}

.issue-field {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

.issue-field-name {
  font-weight: 500;
  color: var(--black);
}

.issue-field-key {
  font-size: 12px;
  line-height: 16px;
  font-weight: 400;
  color: var(--grey-5);
}

.issue-value {
  font-weight: 400;
  color: var(--black);
  word-break: break-word;
}

.issue-value-empty {
  color: var(--grey-4);
}

.issue-desc {
  font-weight: 400;
  color: var(--black);
}

.issue-row-error .issue-desc {
  color: var(--red);
}

.issue-row-warn .issue-desc {
  color: var(--yellow);
}

.issue-arrow {
  display: none;
  flex-shrink: 0;
}

.issue-text {
  min-width: 0;
  word-break: break-word;
}

/* ── Summary grid ────────────────────────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s6);
}

.summary-card {
  background: var(--white);
  border: 1px solid var(--grey-1);
  border-radius: 24px;
  box-shadow: var(--shadow-1);
  padding: var(--s6);
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

.summary-value {
  font-size: 24px;
  font-weight: 600;
  line-height: 28px;
  color: var(--black);
}

.summary-label {
  font-size: 14px;
  font-weight: 400;
  line-height: 18px;
  color: var(--grey-5);
}

.error-card .summary-value { color: var(--red); }
.error-card .summary-label { color: var(--red); }

.warn-card .summary-value { color: var(--yellow); }
.warn-card .summary-label { color: var(--yellow); }

.ok-card .summary-value { color: var(--green); }
.ok-card .summary-label { color: var(--green); }

/* ── Row accordion ───────────────────────────────────────────────────────── */
.rows-block {
  padding: var(--s6);
  gap: 0;
}

.row-item + .row-item {
  margin-top: var(--s6);
  border-top: 1px solid var(--grey-1);
  padding-top: var(--s6);
}

.row-item-header {
  display: flex;
  align-items: center;
  gap: var(--s2);
  cursor: pointer;
  background: transparent;
  user-select: none;
}

.row-meta {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
}

.row-num {
  font-size: 14px;
  line-height: 18px;
  font-weight: 500;
  color: var(--black);
  white-space: nowrap;
  transition: color var(--transition);
}

.row-item-header:hover .row-num {
  color: var(--black-fade);
}

.row-id {
  font-size: 14px;
  line-height: 18px;
  font-weight: 400;
  color: var(--grey-5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-badges {
  display: flex;
  gap: var(--s2);
  flex: 1;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px var(--s2);
  border-radius: var(--s3);
  font-size: 12px;
  font-weight: 500;
  line-height: 12px;
}

.badge-error { background: var(--red-sec); color: var(--red); }
.badge-warn  { background: var(--yellow-sec); color: var(--yellow); }

.row-chevron {
  color: var(--grey-5);
  transition: transform var(--transition), color var(--transition);
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.row-item-header:hover .row-chevron {
  color: var(--black);
}
.row-item.open .row-chevron { transform: rotate(180deg); }

.row-item-body {
  display: none;
  flex-direction: column;
  gap: var(--s2);
  padding-top: var(--s4);
}
.row-item.open .row-item-body {
  display: flex;
}

/* ── Report header (ссылка + название файла) ─────────────────────────────── */
.report-header {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.link-reset {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 400;
  line-height: 18px;
  color: var(--grey-5);
  text-decoration: none;
  transition: color var(--transition);
}

.link-reset:hover {
  color: var(--black);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (min-width: 768px) {
  body { padding-left: 36px; padding-right: 36px; }
}

@media (min-width: 1024px) {
  body { padding-left: 48px; padding-right: 48px; }
}

@media (min-width: 1280px) {
  body { padding-left: 60px; padding-right: 60px; }
}

@media (min-width: 1536px) {
  body { padding-left: 0; padding-right: 0; }
  .container { max-width: 1280px; margin: 0 auto; }
}

@media (max-width: 767px) {
  .summary-grid { grid-template-columns: 1fr; gap: var(--s3); }
  .issue-row { grid-template-columns: 1fr; gap: var(--s2); }
  .issue-field { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: var(--s2); row-gap: var(--s1); }
  .issue-value,
  .issue-desc { display: flex; align-items: flex-start; gap: var(--s2); }
  .issue-arrow { display: block; }
}
