/* Локальные стили — работа без интернета */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --text: #1a1a1a;
  --muted: #5c6773;
  --border: #c5ccd4;
  --sheet-width: 210mm;

  --export-bg: #e4e8ec;
  --export-bg-deep: #d8dde3;
  --export-accent: #3d4f5f;
  --export-accent-light: #566677;
  --export-card: #ffffff;
  --export-panel: #f3f5f7;
  --export-line: #d1d7de;
  --photo-size: 38mm;
  --photo-size-export: 58mm;
}

html {
  font-size: 11pt;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  color: var(--text);
  background: #dfe3e8;
  line-height: 1.45;
}

/* ——— Панель управления ——— */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #2c3e50;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.toolbar h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  flex: 1 1 100%;
}

.toolbar button,
.toolbar label.file-btn {
  padding: 0.45rem 0.85rem;
  border: none;
  border-radius: 4px;
  background: #3498db;
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.toolbar button:hover,
.toolbar label.file-btn:hover {
  background: #2980b9;
}

.toolbar button.secondary {
  background: #7f8c8d;
}

.toolbar button.secondary:hover {
  background: #636e72;
}

.toolbar input[type="file"] {
  display: none;
}

.toolbar .hint {
  font-size: 0.78rem;
  opacity: 0.85;
  flex: 1 1 100%;
}

/* ——— Лист (режим редактирования) ——— */

.document {
  max-width: var(--sheet-width);
  margin: 1.5rem auto 2rem;
}

.export-frame {
  width: var(--sheet-width);
}

.sheet {
  width: 100%;
  background: var(--export-card);
  box-shadow: 0 8px 32px rgba(61, 79, 95, 0.12);
  border: 1px solid var(--export-line);
  overflow: hidden;
}

.sheet-header {
  display: none;
}

.sheet-inner {
  padding: 14mm 16mm 16mm;
}

.section-heading {
  margin: 6mm 0 4mm;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--export-accent);
}

.section-heading:first-child {
  margin-top: 0;
}

/* ——— Личные данные ——— */

.personal {
  display: flex;
  flex-direction: column;
  gap: 3.5mm;
  padding-bottom: 2mm;
  border-bottom: 1px solid var(--export-line);
}

.personal-row {
  display: flex;
  flex-direction: column;
  gap: 1mm;
}

.field-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  font: inherit;
  font-size: 0.95rem;
  padding: 1mm 0 1.5mm;
  resize: none;
  line-height: 1.45;
  color: #222;
}

.field-input:focus {
  outline: none;
  border-bottom-color: var(--export-accent);
}

.personal-top {
  display: flex;
  align-items: flex-start;
  gap: 5mm;
  margin-bottom: 3mm;
}

.personal-side {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2mm;
}

.personal-row-fio .field-fio,
.personal-row-fio .export-value {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.25;
}

.personal-row-age .field-age,
.personal-row-age .export-value {
  font-size: 0.92rem;
  font-weight: 500;
}

.personal-gap {
  height: 4mm;
  flex-shrink: 0;
}

.photo-box {
  width: var(--photo-size);
  height: var(--photo-size);
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.photo-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.photo-box .photo-label {
  display: none;
}

.export-value {
  white-space: pre-wrap;
  line-height: 1.35;
  color: #222;
}

/* ——— Вопросы ——— */

.questions-section {
  padding: 2mm 0;
  border-bottom: 1px solid var(--export-line);
}

.questions-list {
  display: flex;
  flex-direction: column;
  gap: 3mm;
}

.question-item {
  display: flex;
  flex-direction: column;
  gap: 1.5mm;
}

.question-item .q-text {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--export-accent);
}

.question-item textarea {
  width: 100%;
  min-height: 10mm;
  border: 1px solid var(--export-line);
  border-left: 3px solid var(--export-accent-light);
  background: var(--export-panel);
  border-radius: 0 2px 2px 0;
  padding: 2.5mm 3mm;
  font: inherit;
  font-size: 0.9rem;
  resize: vertical;
  line-height: 1.4;
}

.question-item textarea:focus {
  outline: none;
  border-color: var(--export-accent);
  border-left-width: 3px;
  background: #fff;
}

.question-item .export-value {
  background: var(--export-panel);
  border-left: 3px solid var(--export-accent-light);
  padding: 2mm 3mm;
  font-size: 0.88rem;
}

/* ——— Таблица ——— */

.eval-section {
  padding-top: 2mm;
}

.eval-table-wrap {
  overflow-x: auto;
}

.eval-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.eval-table th,
.eval-table td {
  border: 1px solid var(--export-line);
  padding: 2mm 2.5mm;
  text-align: center;
  vertical-align: middle;
}

.eval-table th {
  background: var(--export-accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
}

.eval-table td.criteria {
  text-align: left;
  font-weight: 600;
  background: var(--export-panel);
  color: var(--export-accent);
}

.eval-table th.weight-col {
  min-width: 18mm;
  width: 18mm;
  background: var(--export-accent);
  color: #fff;
}

.eval-table td.weight {
  min-width: 18mm;
  width: 18mm;
  background: #fafbfc;
  color: var(--muted);
  font-size: 0.8rem;
}

.weight-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1mm;
  width: 100%;
}

.eval-table input.weight-input {
  width: 12mm;
  min-width: 52px;
  max-width: none;
  border: 1px solid #9aa8b5;
  border-radius: 3px;
  background: #fff;
  text-align: center;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 2mm 1.5mm;
  color: #111;
  -moz-appearance: textfield;
  appearance: textfield;
}

.eval-table input.weight-input::-webkit-outer-spin-button,
.eval-table input.weight-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.eval-table input.weight-input:focus {
  outline: none;
  border-color: var(--export-accent);
  box-shadow: 0 0 0 2px rgba(61, 79, 95, 0.15);
}

.weight-suffix {
  font-size: 1rem;
  font-weight: 700;
  color: #333;
}

.eval-table td.total-label {
  text-align: right;
  font-weight: 700;
  background: var(--export-panel);
  color: var(--export-accent);
}

.eval-table td.total-value {
  font-weight: 700;
  background: #eef1f4;
  color: #111;
}

.eval-table td.avg-value {
  font-weight: 600;
  background: #f7f9fb;
  color: #333;
}

.eval-table td.overall-value {
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
}

.eval-table input.score-input {
  width: 100%;
  min-width: 40px;
  max-width: 14mm;
  border: 1px solid #c5ccd4;
  border-radius: 3px;
  background: #fff;
  text-align: center;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 1.5mm 1mm;
  color: #111;
  -moz-appearance: textfield;
  appearance: textfield;
}

.eval-table input.score-input::-webkit-outer-spin-button,
.eval-table input.score-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.eval-table input.score-input:focus {
  outline: none;
  border-color: var(--export-accent);
  box-shadow: 0 0 0 2px rgba(61, 79, 95, 0.15);
}

.eval-table input.interviewer-name {
  width: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font: inherit;
  font-weight: 600;
  font-size: 0.75rem;
  padding: 1mm;
  color: #fff;
}

.eval-table th .export-inline {
  color: #fff;
  font-weight: 600;
  font-size: 0.75rem;
}

.eval-table .weighted {
  background: #fafbfc;
  color: #333;
}

.eval-table .gap-col {
  border-left: 2px solid var(--export-accent-light);
}

/* ——— Экспортный режим (PDF / предпросмотр) ——— */

html.export-single-page {
  --ef: var(--export-font-factor, 1);
}

html.export-single-page,
html.export-single-page body {
  background: var(--export-bg) !important;
}

html.export-single-page body {
  display: block;
  min-height: auto;
  margin: 0;
  padding: 0;
}

html.export-single-page .document {
  width: 210mm;
  max-width: none;
  margin: 0;
}

html.export-single-page .export-frame {
  width: 210mm;
  margin: 0;
  transform: none;
}

html.export-single-page .sheet {
  width: 210mm;
  min-height: 297mm;
  background: var(--export-card);
  border: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
}

/* Шапка — на всю ширину листа */
html.export-single-page .sheet-header {
  display: block;
  width: 210mm;
  box-sizing: border-box;
  background: var(--export-accent);
  color: #fff;
  padding: calc(5mm * var(--ef)) calc(8mm * var(--ef));
  margin: 0;
  font-size: calc(10pt * var(--ef));
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  flex-shrink: 0;
}

html.export-single-page .sheet-title {
  display: block;
  width: 100%;
  margin: 0;
  text-align: left;
}

/* Контент — на всю ширину страницы */
html.export-single-page .sheet-inner {
  width: 210mm;
  max-width: none;
  margin: 0;
  padding: calc(5mm * var(--ef)) calc(8mm * var(--ef)) calc(8mm * var(--ef));
  background: var(--export-card);
  border: none;
  box-shadow: none;
  flex: 1;
  min-height: 0;
  box-sizing: border-box;
}

html.export-single-page .personal {
  gap: calc(2.5mm * var(--ef));
  padding-bottom: calc(3mm * var(--ef));
}

html.export-single-page .field-label {
  font-size: calc(8pt * var(--ef));
}

html.export-single-page .export-value,
html.export-single-page .field-input {
  font-size: calc(10.5pt * var(--ef));
  line-height: 1.38;
}

html.export-single-page .section-heading {
  margin: calc(4mm * var(--ef)) 0 calc(3mm * var(--ef));
  font-size: calc(10pt * var(--ef));
  padding-bottom: calc(1.5mm * var(--ef));
  border-bottom: 1.5px solid var(--export-accent);
}

html.export-single-page .questions-list {
  gap: calc(2.5mm * var(--ef));
}

html.export-single-page .question-item .q-text {
  font-size: calc(9.5pt * var(--ef));
}

html.export-single-page .question-item .export-value {
  font-size: calc(10pt * var(--ef));
  padding: calc(2mm * var(--ef)) calc(3mm * var(--ef));
}

html.export-single-page .personal-top {
  display: flex;
  align-items: flex-start;
  gap: calc(4mm * var(--ef));
  margin-bottom: calc(2mm * var(--ef));
}

html.export-single-page .personal-side {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: calc(2mm * var(--ef));
}

html.export-single-page .photo-box {
  width: calc(var(--photo-size-export) * var(--ef));
  height: calc(var(--photo-size-export) * var(--ef));
  background: transparent;
  border: none;
}

html.export-single-page .photo-box img {
  width: calc(var(--photo-size-export) * var(--ef));
  height: calc(var(--photo-size-export) * var(--ef));
  object-fit: contain;
}

html.export-single-page .field-label-fio,
html.export-single-page .field-label-age {
  display: none;
}

html.export-single-page .personal-row-fio .export-value,
html.export-single-page .personal-row-fio .field-fio {
  font-size: calc(16pt * var(--ef));
  font-weight: 700;
  line-height: 1.2;
}

html.export-single-page .personal-row-age .export-value,
html.export-single-page .personal-row-age .field-age {
  font-size: calc(11pt * var(--ef));
  font-weight: 500;
}

html.export-single-page .personal-gap {
  height: calc(3mm * var(--ef));
}

html.export-single-page .personal-side .personal-row-fio {
  gap: 0;
}

html.export-single-page .personal-side .personal-row-age {
  gap: 0;
  margin-top: 0.5mm;
}

html.export-single-page .eval-table {
  font-size: calc(9.5pt * var(--ef));
}

html.export-single-page .eval-table th {
  font-size: calc(8.5pt * var(--ef));
  padding: calc(1.5mm * var(--ef)) calc(2mm * var(--ef));
}

html.export-single-page .eval-table td {
  padding: calc(1.5mm * var(--ef)) calc(2mm * var(--ef));
}

html.export-single-page .eval-table td.total-value,
html.export-single-page .eval-table td.avg-value,
html.export-single-page .eval-table td.overall-value {
  font-size: calc(10pt * var(--ef));
}

/* ——— Печать / PDF ——— */

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  html.export-single-page,
  html.export-single-page body {
    width: 210mm;
    height: auto;
    min-height: 297mm;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    display: block !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .no-print {
    display: none !important;
  }

  html.export-single-page .document {
    margin: 0;
    padding: 0;
    width: 210mm;
    height: auto;
    overflow: visible;
    background: var(--export-bg) !important;
  }

  html.export-single-page .export-frame {
    transform: none !important;
    width: 210mm !important;
    margin: 0;
    height: auto;
  }

  html.export-single-page .sheet {
    width: 210mm;
    min-height: 297mm;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  html.export-single-page .sheet-header,
  html.export-single-page .sheet-inner {
    width: 210mm;
    margin: 0;
  }

  html.export-single-page .sheet-inner {
    padding: calc(5mm * var(--ef)) calc(8mm * var(--ef)) calc(8mm * var(--ef));
  }

  html.export-single-page .sheet-header,
  html.export-single-page .sheet-inner,
  html.export-single-page .question-item .export-value,
  html.export-single-page .eval-table th,
  html.export-single-page .eval-table td.criteria,
  html.export-single-page .eval-table td.total-label,
  html.export-single-page .eval-table td.weight,
  html.export-single-page .eval-table .weighted,
  html.export-single-page .photo-box {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .personal,
  .questions-section,
  .eval-section,
  .question-item,
  .eval-table-wrap {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  html.export-single-page {
    font-size: calc(11pt * var(--ef, 1));
    line-height: 1.38;
  }

  textarea,
  input {
    border: none !important;
    overflow: visible;
  }

  .question-item textarea {
    border: none !important;
    min-height: auto;
    padding: 0;
    background: transparent !important;
  }

  .field-input {
    border-bottom: none !important;
  }
}
