:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #6b7686;
  --accent: #2b59d9;
  --line: #e3e7ee;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 12px; }
.logo { font-weight: 700; font-size: 20px; color: var(--text); }
.logo:hover { text-decoration: none; }
.nav { display: flex; gap: 16px; flex-wrap: wrap; }
.main { flex: 1; padding-top: 48px; padding-bottom: 48px; }
.hero { text-align: center; padding: 48px 0; }
.hero h1 { font-size: 40px; margin: 0 0 12px; line-height: 1.15; }
.lead { font-size: 20px; margin: 0 0 8px; }
.muted { color: var(--muted); margin: 0; }
.site-footer { border-top: 1px solid var(--line); background: var(--card); padding: 20px 0; color: var(--muted); font-size: 14px; }
/* Карточки, формы, кнопки (вход, кабинет) */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 28px; margin: 0 auto 20px; max-width: 760px; }
.card.narrow { max-width: 440px; }
.card h1 { font-size: 26px; line-height: 1.25; margin: 0 0 12px; }
.card h2 { font-size: 20px; line-height: 1.3; margin: 0 0 8px; }
.card p { margin: 0 0 12px; }
.card > :last-child { margin-bottom: 0; }
.form { display: flex; flex-direction: column; gap: 16px; margin-top: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 600; font-size: 15px; }
.field input { font: inherit; font-size: 18px; padding: 12px 14px; border: 1px solid #c9d0db; border-radius: 10px; background: #fff; color: var(--text); width: 100%; min-height: 50px; }
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.code-input { letter-spacing: 0.35em; font-variant-numeric: tabular-nums; font-size: 24px !important; text-align: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; font: inherit; font-weight: 600; font-size: 17px; padding: 12px 22px; min-height: 50px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #2149b8; }
.btn-secondary { background: var(--card); color: var(--text); border-color: #c9d0db; }
.btn-secondary:hover { background: #eef1f6; }
.btn-wide { width: 100%; }
.link-btn { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.nav { align-items: center; }
.nav-form { margin: 0; }
.alert { border-radius: 10px; padding: 12px 14px; margin: 12px 0; font-size: 15px; }
.alert-error { background: #fdecec; color: #8f1d1d; border: 1px solid #f5c2c2; }
.alert-ok { background: #eaf6ee; color: #1d5b31; border: 1px solid #bfe3ca; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 18px; font-size: 15px; }
.auth-links form { margin: 0; }
.cabinet-logout { max-width: 760px; margin: 0 auto; }
.cabinet-cta { margin-top: 16px !important; }
/* Поле-ловушка для ботов: убрано с экрана, но есть в форме */
.hp-field { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
@media (max-width: 600px) {
  .card { padding: 20px 16px; border-radius: 10px; }
  .card h1 { font-size: 22px; }
  .auth-links { flex-direction: column; align-items: flex-start; }
  .cabinet-logout .btn { width: 100%; }
  .main { padding-top: 24px; padding-bottom: 24px; }
  .hero { padding: 24px 0; }
  .hero h1 { font-size: 30px; }
  .lead { font-size: 18px; }
}

/* ===== Кабинет / страницы ошибок (T5) ===== */
.small { font-size: 14px; }
.btn-danger { background: var(--card); color: #b42318; border-color: #efb8b2; }
.btn-danger:hover { background: #fdecec; }
.btn-danger-solid { background: #c4321f; color: #fff; }
.btn-danger-solid:hover { background: #a3281a; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.inline-form { margin: 0; }
/* Кабинет */
.cabinet { max-width: 760px; margin: 0 auto; }
.cabinet > .alert { margin: 0 0 16px; }
.cabinet-head { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; }
.cabinet-head-text { min-width: 0; }
.cabinet-head-text .muted { margin: 0; }
.cabinet-email { color: var(--text); overflow-wrap: anywhere; }
.cabinet-head-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-head h2 { margin: 0 !important; }
.counter { flex: none; font-size: 14px; font-weight: 600; color: var(--muted); background: #eef1f6; border-radius: 999px; padding: 4px 12px; white-space: nowrap; }
.empty-state { border: 1px dashed #c9d0db; border-radius: 10px; padding: 24px; text-align: center; background: #fbfcfd; }
.empty-state p { color: var(--muted); max-width: 520px; margin: 0 auto 16px !important; }
.stamp-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.stamp-item { display: grid; grid-template-columns: 80px minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
/* Шахматный фон — видно, что фон у печати прозрачный */
.stamp-thumb { width: 80px; height: 80px; border-radius: 8px; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; overflow: hidden;
  background-color: #fff; background-image: linear-gradient(45deg, #eef1f6 25%, transparent 25%, transparent 75%, #eef1f6 75%), linear-gradient(45deg, #eef1f6 25%, transparent 25%, transparent 75%, #eef1f6 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px; }
.stamp-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.stamp-thumb-lg { width: 160px; height: 160px; margin: 8px 0 16px; }
.stamp-info { min-width: 0; }
.stamp-name { font-weight: 600; overflow-wrap: anywhere; }
.stamp-meta { color: var(--muted); font-size: 14px; }
.stamp-delete { min-height: 44px; padding: 8px 16px; font-size: 15px; }
.note { background: #fbfcfd; }
.note .muted { font-size: 15px; }
/* Страница ошибки */
.error-code { color: var(--muted); font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 6px !important; }
.error-details { margin-top: 20px; padding: 12px; background: #f3f4f6; border-radius: 8px; font-size: 12px; overflow: auto; max-height: 320px; white-space: pre-wrap; }
@media (max-width: 600px) {
  .cabinet-head-actions, .cabinet-head-actions .inline-form, .cabinet-head-actions .btn { width: 100%; }
  .actions .btn { flex: 1 1 100%; }
  .stamp-item { grid-template-columns: 64px minmax(0, 1fr); gap: 10px 12px; }
  .stamp-thumb { width: 64px; height: 64px; }
  .stamp-delete { grid-column: 2; justify-self: start; }
  .empty-state { padding: 20px 16px; }
  .empty-state .btn { width: 100%; }
}
