/* DocGen — mobile-first. Базовые правила рассчитаны на экран 375–430 px,
   десктоп получает те же блоки в более широкой сетке. */

:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #dfe3e8;
  --text: #1c2530;
  --muted: #6b7785;
  --accent: #2a5bd7;
  --danger: #b3261e;
  --warn-bg: #fff6e0;
  --warn-line: #e8c26a;
  --tap: 46px;              /* минимальная высота элемента для пальца */
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 16px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-wrap: anywhere;     /* длинные id и email не рвут вёрстку */
}

/* шапка и вкладки */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }

.tabs {
  display: flex;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.tabs a {
  flex: 1;
  text-align: center;
  padding: 13px 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
  min-height: var(--tap);
}
.tabs a.active { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); font-weight: 600; }

main { padding: 16px; max-width: 900px; margin: 0 auto; }

h1 { font-size: 21px; margin: 0 0 14px; }
h2 { font-size: 17px; margin: 22px 0 10px; }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.hint { color: var(--muted); font-weight: 400; font-size: 13px; }
a { color: var(--accent); }

/* кнопки: крупные, во всю ширину на телефоне */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 11px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
  margin-bottom: 8px;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.button.big { min-height: 52px; font-size: 17px; }
.button.danger { color: var(--danger); border-color: #e8c9c7; }
.button:active { transform: translateY(1px); }
.inline { display: inline; }

.actions { display: flex; flex-direction: column; margin: 14px 0; }

/* карточки */

.cards { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.card h2 { margin: 0 0 6px; font-size: 18px; }
.card h2 a { text-decoration: none; }

.badge { display: inline-block; padding: 3px 12px; border-radius: 20px; font-size: 14px; background: #eef1f5; border: 1px solid var(--line); }
.badge.good { background: #e7f6ec; border-color: #a8d8b9; }
.badge.review { background: var(--warn-bg); border-color: var(--warn-line); }
.badge.failed { background: #fdecea; border-color: #e8b4b0; }

.facts { display: flex; gap: 20px; margin: 12px 0 0; flex-wrap: wrap; }
.facts.stacked { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px; }
.facts.stacked div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.facts.stacked div:last-child { border-bottom: none; }
.facts dt { font-size: 14px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; }

/* таблицы: на телефоне читаются как список пар */

table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: 15px; }
table.grid th, table.grid td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { background: #eef1f5; font-size: 13px; color: var(--muted); }
table.grid tr:last-child td { border-bottom: none; }
table.grid td:first-child { color: var(--muted); width: 42%; }

.list { padding-left: 18px; }
.list li { margin: 6px 0; }

.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; padding: 28px 16px; text-align: center; color: var(--muted); }

/* сообщения */

.flash { padding: 12px 14px; border-radius: 10px; margin: 0 0 14px; border: 1px solid var(--line); background: var(--panel); }
.flash.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.flash.error { background: #fdecea; border-color: #e8b4b0; }
.warn-list { margin: 8px 0 0; padding-left: 20px; }

/* формы: одна колонка, крупные поля */

form.stack { display: flex; flex-direction: column; gap: 12px; }
form.stack label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; color: var(--muted); }
label.check, label.inline-check { flex-direction: row; align-items: center; gap: 8px; }

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  font: inherit;
  font-size: 16px;            /* мельче — iOS зумит страницу при фокусе */
  color: var(--text);
  padding: 11px 12px;
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  width: 100%;
}
textarea { resize: vertical; }
input[type="color"] { width: 56px; height: 44px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
input[type="file"] { font-size: 15px; }

fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--panel); display: flex; flex-direction: column; gap: 12px; margin: 0; }
legend { font-size: 14px; color: var(--muted); padding: 0 6px; }

.block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.block h2 { margin: 0; font-size: 16px; }
.picker { font-weight: 600; color: var(--text); }

.row { display: flex; gap: 12px; }
.row > label { flex: 1; }

/* предпросмотр PDF */

.preview { margin: 14px 0; }
.preview iframe {
  width: 100%;
  height: 62vh;
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.preview-side { display: flex; flex-direction: column; gap: 12px; }

/* вход */

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: 100%; max-width: 360px; }
.login h1 { text-align: center; }

/* диагностика (технический экран) */

.steps { color: var(--muted); line-height: 1.7; padding-left: 20px; }
.steps code { background: #eef1f5; padding: 1px 5px; border-radius: 4px; }
.compare-row { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.compare-row figure { margin: 0; }
.compare-row figcaption { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.compare-row img { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.pages { display: flex; align-items: center; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.page-link { display: inline-block; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); text-decoration: none; }
.page-link.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.editor { display: flex; flex-direction: column; gap: 16px; }
.canvas-wrap { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; user-select: none; }
.canvas-wrap img { display: block; width: 100%; height: auto; }
.field-box { position: absolute; border: 1.5px solid var(--accent); background: rgba(42,91,215,.10); cursor: pointer; }
.field-box.selected { border-color: var(--danger); background: rgba(179,38,30,.12); }
.field-box span { position: absolute; top: -17px; left: -1px; font-size: 10px; line-height: 15px; padding: 0 4px; white-space: nowrap; background: var(--accent); color: #fff; border-radius: 3px 3px 0 0; }
.field-box.selected span { background: var(--danger); }
#selection { position: absolute; border: 1.5px dashed var(--danger); background: rgba(179,38,30,.08); pointer-events: none; }
.side { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.coords { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inline-form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

/* десктоп: те же блоки, шире */

@media (min-width: 760px) {
  main { padding: 24px; }
  .tabs { justify-content: flex-start; }
  .tabs a { flex: 0 0 auto; padding: 13px 22px; }
  .button { width: auto; margin-bottom: 0; }
  .actions { flex-direction: row; flex-wrap: wrap; gap: 10px; }
  .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  form.stack { max-width: 640px; }
  .row { flex-direction: row; }
  .compare-row { display: grid; grid-template-columns: repeat(3, 1fr); }
  .editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .preview iframe { height: 78vh; }
}
