:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #d9dee7;
  --text: #172033;
  --muted: #687386;
  --accent: #176b5d;
  --accent-dark: #0f4f45;
  --danger: #b42318;
  --warning: #9a6700;
  --ok: #1f7a42;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 15px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topnav a {
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}

.topnav form {
  margin: 0;
}

.mode,
.muted,
small {
  color: var(--muted);
}

.page {
  width: min(1280px, calc(100% - 32px));
  margin: 24px auto 56px;
}

.band,
.form-section,
.issues,
.review-head {
  margin-bottom: 20px;
}

.panel,
.form-section,
.issues {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.form-section {
  padding-top: 0;
  overflow: hidden;
}

h1,
h2 {
  margin: 0 0 14px;
  letter-spacing: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 18px;
}

.section-subtitle {
  margin: 18px 0 10px;
  color: var(--text);
  font-size: 15px;
  font-weight: 750;
}

.form-section h2 {
  margin: 0 -20px 20px;
  padding: 13px 20px;
  text-align: center;
  color: var(--accent-dark);
  background: #eef6f4;
  border-bottom: 1px solid #c7ded8;
  font-size: 17px;
  font-weight: 750;
}

.upload-panel {
  max-width: 760px;
}

.login-panel {
  max-width: 560px;
}

.login-form,
.settings-form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.login-actions {
  margin: 18px 0;
}

.warning-text {
  color: var(--warning);
}

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

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-form select {
  min-width: 140px;
}

.jobs-filter {
  margin: 10px 0 14px;
}

.source-file-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.source-file-cell > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.source-download-button {
  display: inline-flex;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent-dark);
  background: #fff;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.source-download-button:hover {
  border-color: var(--accent);
  background: #eef6f4;
}

.copy-list code {
  background: #eef2f6;
  border-radius: 4px;
  padding: 2px 6px;
}

.upload-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.text-recognition-actions {
  margin-top: 14px;
}

.text-recognition-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.text-recognition-form[hidden] {
  display: none;
}

.text-recognition-form label {
  display: grid;
  gap: 8px;
}

.text-recognition-submit {
  display: flex;
  justify-content: flex-end;
}

.file-box {
  display: grid;
  gap: 8px;
}

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

textarea {
  resize: vertical;
}

.primary-button,
.small-button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.small-button {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.link-button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  background: #eef2f6;
  font-size: 13px;
  color: #435066;
}

.review-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.head-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.issues {
  border-color: #f2b8b5;
  background: #fff7f6;
}

.issues h2,
.error-text {
  color: var(--danger);
}

.issues li {
  margin: 6px 0;
}

.issue-field-link {
  color: var(--danger);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.issue-field-link:hover {
  text-decoration-thickness: 2px;
}

.review-form {
  display: grid;
  gap: 8px;
}

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

.form-field {
  display: grid;
  gap: 6px;
  scroll-margin-top: 18px;
}

.form-field.field-blocker > input,
.form-field.field-blocker > select,
.form-field.field-blocker > textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(176, 45, 36, .12);
}

.form-field.field-blocker > span:first-child {
  color: var(--danger);
}

.form-field.field-blocker:target > input,
.form-field.field-blocker:target > select,
.form-field.field-blocker:target > textarea {
  box-shadow: 0 0 0 4px rgba(176, 45, 36, .22);
}

.form-field > span:first-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.wide {
  grid-column: 1 / -1;
}

.field-status {
  width: max-content;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.field-status.найдено {
  border-color: #9fd4b2;
  color: var(--ok);
  background: #f0fbf4;
}

.field-status.сомнительно {
  border-color: #e0c06b;
  color: var(--warning);
  background: #fff8e1;
}

.field-status.не-найдено {
  border-color: #efaaa5;
  color: var(--danger);
  background: #fff4f3;
}

.doc-grid,
.site-grid,
.requirements-grid,
.product-appendix-grid {
  display: grid;
  gap: 10px;
}

.repeatable-field {
  display: grid;
  gap: 10px;
}

.doc-grid {
  grid-template-columns: 1fr 2fr 1fr 1fr;
}

.site-grid {
  grid-template-columns: 1.2fr 2fr .8fr .8fr .8fr;
}

.requirements-grid {
  grid-template-columns: 1fr 2fr 1fr;
}

.product-appendix-grid {
  grid-template-columns: 1fr 1fr 2fr 2fr;
}

.repeater-row {
  display: contents;
}

.add-row-button {
  justify-self: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 11px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.add-row-button:hover {
  border-color: #34a9d4;
  color: #177da3;
}

.tag-select {
  position: relative;
  width: 100%;
}

.tag-select-control {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.tag-select.open .tag-select-control {
  border-color: #34a9d4;
  box-shadow: 0 0 0 2px rgba(52, 169, 212, .14);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1 1 auto;
  min-width: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border-radius: 4px;
  padding: 5px 7px;
  background: #d6f0fb;
  color: #315568;
  font-size: 13px;
  line-height: 1.15;
}

.tag-placeholder {
  display: none;
  flex: 1 1 auto;
  color: var(--muted);
}

.tag-list:empty + .tag-placeholder {
  display: block;
}

.tag-arrow {
  flex: 0 0 auto;
  margin-left: auto;
  color: #42526a;
  font-size: 18px;
}

.tag-select-menu {
  display: none;
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 0 0 12px 12px;
  background: #fff;
  box-shadow: 0 14px 28px rgba(19, 31, 49, .12);
}

.tag-select.open .tag-select-menu {
  display: grid;
}

.tag-option {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px 11px;
  color: #6a7280;
  cursor: pointer;
  user-select: none;
}

.tag-option:hover,
.tag-option:has(input:checked) {
  background: #f0f3f6;
}

.tag-option input {
  width: 15px;
  height: 15px;
  margin-top: 2px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 0;
  background: linear-gradient(to top, var(--bg) 70%, rgba(246, 247, 249, 0));
}

@media (max-width: 820px) {
  .topbar,
  .review-head,
  .upload-form {
    display: grid;
  }

  .page {
    width: min(100% - 20px, 1280px);
    margin-top: 14px;
  }

  .form-grid,
  .doc-grid,
  .site-grid,
  .requirements-grid,
  .product-appendix-grid {
    grid-template-columns: 1fr;
  }

  .head-actions,
  .sticky-actions {
    justify-content: stretch;
  }

  .primary-button,
  .small-button {
    width: 100%;
  }
}
