:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1a1f2b;
  --muted: #5c6578;
  --line: #e2e7ef;
  --accent: #0f5f8c;
  --accent-soft: #e6f2f8;
  --danger: #b42318;
  --ok: #0f7a45;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

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

.hidden {
  display: none !important;
}

.app-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(165deg, #eef3f8 0%, #f8fafc 45%, #e8f0f6 100%);
}

.login-main {
  width: min(560px, 100%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 2rem 2rem 1.75rem;
}

.login-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.login-hint {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-field span {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.login-field input {
  width: 100%;
}

#loginBtn {
  width: 100%;
  padding: 0.8rem 1rem;
  font-weight: 600;
}

.login-noscript {
  max-width: 40rem;
  margin: 2rem auto;
  padding: 1rem;
  text-align: center;
}

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

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 1.25rem;
}

.main {
  padding: 1.5rem 2rem 2.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.row > * {
  flex: 1 1 240px;
}

/* Шаги 2–3: чек-лист / журнал и превью документа по половине ширины (читабельный PDF). */
.row.review-row {
  align-items: flex-start;
  flex-wrap: nowrap;
}

.row.review-row > .review-main {
  flex: 1 1 0;
  min-width: 0;
}

.row.review-row > .review-preview {
  flex: 1 1 0;
  min-width: 0;
}

@media (max-width: 900px) {
  .row.review-row {
    flex-wrap: wrap;
  }

  .row.review-row > .review-main,
  .row.review-row > .review-preview {
    flex: 1 1 100%;
  }
}

h1,
h2,
h3 {
  margin: 0 0 0.5rem;
  line-height: 1.25;
}

.lead {
  color: var(--muted);
  margin: 0 0 1rem;
}

label {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  background: #fff;
}

button {
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

button.secondary {
  background: #eef2f7;
  color: var(--text);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #b9d9ea;
}

.metric {
  font-size: 1.5rem;
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
}

.field-list {
  display: grid;
  gap: 0.75rem;
  max-height: 70vh;
  overflow: auto;
}

.field-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
}

.field-item.empty {
  opacity: 0.75;
}

.extra-fields-details {
  margin-top: 1rem;
  padding: 0.5rem 0.65rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fafbfc;
}

.extra-fields-details > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}

.extra-fields-details[open] > summary {
  color: var(--text);
  margin-bottom: 0.5rem;
}

.field-item.extra-field {
  background: #fff;
}

.preview-pane iframe,
.preview-pane img {
  width: 100%;
  min-height: 70vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

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

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: #111827;
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 8px;
}

.warn {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  padding: 0.75rem;
  border-radius: 8px;
}

.report-role-note {
  margin-bottom: 1.25rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

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

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.15rem;
}

.kpi-card h3 {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.status-pill {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.status-pass {
  background: #dcfce7;
  color: var(--ok);
}

.status-fail {
  background: #fee2e2;
  color: var(--danger);
}

.status-na {
  background: #f1f5f9;
  color: var(--muted);
}

.report-table {
  font-size: 0.88rem;
}

.report-table th {
  white-space: nowrap;
}

.export-toolbar {
  padding: 1rem 1.15rem;
}

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

.methodology-block {
  padding: 1rem 1.15rem;
}

.methodology-block summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}

.methodology-list {
  margin: 0.65rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.dashboard-root > .card.stack h3 {
  font-size: 1rem;
}

.reference-panel {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  background: var(--accent-soft);
  border: 1px solid #cfe4f0;
}

.reference-panel details {
  margin-top: 0.65rem;
}

.reference-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}

.reference-panel .lead {
  margin-bottom: 0.5rem;
}

.reference-panel table {
  table-layout: fixed;
  font-size: 0.82rem;
}

.reference-panel th,
.reference-panel td {
  padding: 0.35rem 0.45rem;
  line-height: 1.35;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.reference-panel td code {
  font-size: 0.8em;
  white-space: normal;
  word-break: break-word;
}

.reference-panel th:nth-child(1),
.reference-panel td:nth-child(1) {
  width: 22%;
}

.reference-panel th:nth-child(2),
.reference-panel td:nth-child(2) {
  width: 26%;
}

.reference-panel th:nth-child(3),
.reference-panel td:nth-child(3) {
  width: 52%;
}

.postings-pre {
  margin: 0.35rem 0 0;
  padding: 0.65rem 0.75rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 22rem;
  overflow: auto;
}

.posting-group {
  margin-bottom: 0.85rem;
}

.muted.small {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.2rem 0 0.35rem;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
}
