/* ============================================================
   Общие стили. Переменные, кнопки, карточки, поля, модалки.
   ============================================================ */
:root {
  --primary: #2563eb; --primary-dark: #1d4ed8;
  --bg: #eef2f7; --text: #1e293b; --text2: #334155;
  --muted: #64748b; --border: #e2e8f0;

  --success: #15803d; --success-bg: #dcfce7;
  --danger: #b91c1c;  --danger-bg: #fee2e2;
  --warn: #b45309;    --warn-bg: #fef3c7;
  --info: #1d4ed8;    --info-bg: #dbeafe;
  --purple: #6d28d9;  --purple-bg: #ede9fe;


  --lime: #14b8a6;
  --lime-soft: rgba(20, 184, 166, .22);

  --shadow: 0 10px 30px rgba(15,23,42,.08);
  --shadow-lg: 0 20px 50px rgba(15,23,42,.15);
}

* {
  box-sizing: border-box; margin: 0; padding: 0;
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body { background: var(--bg); color: var(--text2); }

.hidden { display: none !important; }
.mono { font-family: ui-monospace, Consolas, monospace; }

/* ---------- Кнопки ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px;
  height: 44px; padding: 0 22px; min-width: 120px;
  border: 1px solid rgba(15,23,42,.10); border-radius: 10px;
  font-size: 14px; font-weight: 800; font-family: inherit;
  cursor: pointer; white-space: nowrap; line-height: 1;
  overflow: hidden; isolation: isolate; user-select: none;
  transition: transform .1s, background-color .12s, box-shadow .12s;
  text-decoration: none;
}
.btn:active:not(:disabled) { transform: scale(.96); }
/* окантовка загорается только при фокусе с клавиатуры (для доступности) */
.btn:focus-visible { outline: 3px solid rgba(37,99,235,.45); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ico { font-size: 15px; }

.btn.primary { background: var(--primary); color: #fff;
  box-shadow: 0 4px 10px rgba(37,99,235,.25); }
.btn.primary:active:not(:disabled) { background: var(--primary-dark); }

.btn.ghost { background: #f1f5f9; color: var(--text2); }
.btn.ghost:active:not(:disabled) { background: #e2e8f0; }

.btn.success { background: #16a34a; color: #fff; }
.btn.success:active:not(:disabled) { background: #15803d; }

.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:active:not(:disabled) { background: #991b1b; }

.btn.sm { height: 38px; padding: 0 16px; font-size: 13px; min-width: 100px; }
.btn.block { width: 100%; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- Карточки ---------- */
.card {
  background: #fff; border-radius: 16px;
  box-shadow: var(--shadow); padding: 20px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h2 {
  font-size: 15px; font-weight: 800; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.card-head .hint { font-size: 11.5px; color: var(--muted); font-weight: 600; }

/* ---------- Поля ---------- */
.field-group { display: flex; flex-direction: column; gap: 10px; }
.input {
  width: 100%; padding: 14px 16px;
  border: 2px solid var(--border); border-radius: 12px;
  font-size: 15px; font-family: inherit; color: var(--text);
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
.input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}
.input::placeholder { color: #94a3b8; }
.input.pin {
  font-size: 26px; font-weight: 800; text-align: center;
  letter-spacing: .5em; padding: 18px 16px; text-indent: .5em;
  font-family: ui-monospace, Consolas, monospace;
}

/* ---------- Модалки ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: #fff; border-radius: 20px;
  padding: 32px 28px 24px; width: 100%; max-width: 400px;
  box-shadow: 0 30px 70px rgba(15,23,42,.28); text-align: center;
}
.modal-card h3 {
  font-size: 20px; font-weight: 800; color: var(--text);
  margin-bottom: 6px;
}
.modal-card p {
  font-size: 13px; color: var(--muted);
  line-height: 1.5; margin-bottom: 20px;
}
.modal-icon {
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; margin: 0 auto 14px;
}
.modal-icon.lock { background: var(--info-bg); color: var(--primary); }
.modal-icon.pin { background: linear-gradient(135deg,#fef3c7,#fde68a); color: var(--warn); }
.modal-actions {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin-top: 8px;
}
.modal-actions .btn { width: 100%; min-width: 0; }
.auth-err {
  font-size: 13px; font-weight: 700; color: var(--danger);
  text-align: center; min-height: 20px; padding: 4px 0; line-height: 1.4;
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; top: 20px; right: 24px; z-index: 400;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  background: #fff; border-left: 4px solid var(--primary);
  border-radius: 10px; padding: 12px 16px;
  box-shadow: 0 12px 28px rgba(0,0,0,.14);
  font-size: 13.5px; font-weight: 700; min-width: 220px; max-width: 320px;
  animation: slideIn .25s ease;
}
@keyframes slideIn {
  from { transform: translateX(30px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }
.toast.warn    { border-color: #f59e0b; color: var(--warn); }

/* ---------- Switch ---------- */
.switch {
  position: relative; display: inline-block;
  width: 52px; height: 28px; flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #cbd5e1; border-radius: 99px; transition: .2s;
}
.slider:before {
  position: absolute; content: ""; height: 20px; width: 20px;
  left: 4px; bottom: 4px; background: #fff; border-radius: 50%;
  transition: .2s; box-shadow: 0 2px 4px rgba(0,0,0,.15);
}
input:checked + .slider { background: var(--success); }
input:checked + .slider:before { transform: translateX(24px); }
input:disabled + .slider { opacity: .5; cursor: not-allowed; }

/* ---------- Враппер ---------- */
.wrap { max-width: 1320px; margin: 0 auto; }

/* ---------- Выбор страниц (общий паттерн для print/scan) ---------- */
.page-thumb {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, opacity .15s;
  background: #fff;
}
.page-thumb img {
  width: 100%; height: 100%;
  object-fit: contain; display: block;
}
.page-thumb.selected {
  border-color: var(--lime);
  box-shadow: 0 0 0 3px var(--lime-soft);
}
.page-thumb:not(.selected) img {
  opacity: .35;
  filter: grayscale(.5);
}
.page-thumb .num {
  position: absolute; left: 4px; bottom: 4px;
  background: rgba(15,23,42,.7); color: #fff;
  font-size: 10.5px; font-weight: 800;
  padding: 1px 6px; border-radius: 6px;
  font-family: ui-monospace, Consolas, monospace;
}


/* ---------- Шапка страницы: ОДИН стиль на всех экранах ----------
   Единственный вариант шапки — .page-head: градиент во всю ширину карточки,
   заголовок h1 и подзаголовок .subtitle. Полос .card-bar у кнопок и блоков
   больше нет: они выглядели как «шапки» на кнопках. Цвета — из палитры выше. */
.page-head {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff; padding: 22px 24px; text-align: center;
  box-shadow: 0 4px 16px rgba(37,99,235,.25);
}
.page-head h1 { font-size: 22px; font-weight: 800; margin: 0 0 4px; }
.page-head .sub, .page-head .subtitle { font-size: 13.5px; opacity: .92; }

/* Подпись над счётчиком напечатанных листов */
.counter-cap {
    font-size: 12px;
    letter-spacing: .04em;
    text-transform: uppercase;
    opacity: .6;
    margin-top: 6px;
}
