:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --border: #e4e6eb;
  --text: #1c1e26;
  --text-muted: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0fe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand:hover {
  color: var(--text);
  text-decoration: none;
}

.brand__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.header__user {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  color: var(--text-muted);
}

.header__user form {
  display: inline;
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 24px;
}

.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 20px;
}

.filters__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}

@media (max-width: 640px) {
  .filters__grid {
    grid-template-columns: 1fr 1fr;
  }
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="date"],
.field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 14px;
  color: var(--text);
}

.field input[type="text"]:focus,
.field input[type="password"]:focus,
.field input[type="date"]:focus,
.field select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
  text-decoration: none;
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.result-count {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.tender-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tender-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: block;
  color: inherit;
}

.tender-card:hover {
  border-color: var(--accent);
}

/* Карточка — не ссылка целиком (внутри есть своя ссылка на заказчика,
   а вложенные <a> невалидны и ломают клик). Накладываем прозрачную ссылку
   на всю карточку поверх контента, а то, что должно оставаться кликабельным
   самостоятельно (ссылка на заказчика), поднимаем выше неё через z-index. */
.tender-card__open {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.tender-card__customer-link {
  position: relative;
  z-index: 2;
  text-decoration: underline;
}

.tender-card__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 6px;
}

.tender-card__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.tender-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}

.tender-card__meta span strong {
  color: var(--text);
  font-weight: 500;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.badge-outline {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 28px;
}

.pagination a,
.pagination span {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
}

.pagination a:hover {
  border-color: var(--accent);
  text-decoration: none;
  color: var(--accent);
}

.pagination .current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--text-muted);
}

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 28px;
  margin-bottom: 20px;
}

.detail-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 12px;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px 24px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.detail-grid dt {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-grid dd {
  margin: 0;
  font-size: 14px;
  word-break: break-word;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 14px;
}

.fields-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.fields-table th,
.fields-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.fields-table th {
  width: 32%;
  color: var(--text-muted);
  font-weight: 500;
}

.fields-table tr:last-child th,
.fields-table tr:last-child td {
  border-bottom: none;
}

.doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doc-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}

.auth-card h1 {
  font-size: 18px;
  margin: 0 0 20px;
  text-align: center;
}

.auth-card .field {
  margin-bottom: 14px;
}

.auth-card .errorlist {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  color: #b42318;
  font-size: 13px;
}

.auth-card .helptext {
  display: none;
}

.auth-card .btn {
  width: 100%;
  margin-top: 6px;
}

/* Сравнение документов */

.compare-form {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: end;
}

.compare-form .field {
  flex: 1 1 260px;
}

.compare-form .field--auto {
  flex: 0 0 auto;
}

.field input[type="file"] {
  width: 100%;
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 13px;
  color: var(--text);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: -2px;
}

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

.loading-state {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 18px;
}

/* .loading-state и [hidden] — оба класс/атрибутные селекторы, то есть
   одинаковой специфичности; без этого правила display:flex выше побеждал бы
   родное скрытие через hidden, и спиннер был бы виден ещё до всякой загрузки. */
.loading-state[hidden] {
  display: none;
}

.loading-state .spinner {
  border-color: var(--border);
  border-top-color: var(--accent);
}

.alert-error {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b42318;
  font-size: 14px;
  line-height: 1.5;
}

.alert-error strong {
  display: block;
  margin-bottom: 4px;
}

.alert-success {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
  font-size: 14px;
  line-height: 1.5;
}

.stoplist-log {
  margin-top: 12px;
  padding: 10px 14px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.6;
}

.compare-result {
  margin-top: 20px;
}

.compare-result__actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.compare-result__frame {
  width: 100%;
  height: 80vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.stats-summary {
  display: flex;
  gap: 24px;
  margin: 16px 0;
}

.stats-summary__item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 18px;
}

.stats-summary__value {
  font-size: 22px;
  font-weight: 700;
}

.stats-summary__label {
  font-size: 13px;
  color: var(--text-muted);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.stats-table th,
.stats-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.stats-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stats-table td:nth-child(2) {
  white-space: nowrap;
  text-align: right;
}

.stats-table tr:last-child td {
  border-bottom: none;
}

.stats-table__example {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
