/* ============================================================
   DocPrint 2.0 — современная «друкарня»: бумага, гарнитура Plex,
   спокойный синий бренд, точечный золотой акцент.
   Компонентный API описан в app/web/DESIGN.md
   ============================================================ */

:root {
  /* --- палитра --- */
  --paper: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f0f1ed;
  --ink: #171a20;
  --ink-2: #565e6a;
  --ink-3: #8a919c;
  --line: #e6e7e2;
  --line-2: #d4d6d0;
  --brand: #24418f;
  --brand-strong: #1a3170;
  --brand-soft: #e9eef9;
  --brand-ink: #ffffff;
  --gold: #ffd500;
  --ok: #1c7c3f;         --ok-soft: #e5f3e9;
  --warn: #9a5b12;       --warn-soft: #fcf0dc;
  --err: #b3261e;        --err-soft: #fcebea;
  --info: #24418f;       --info-soft: #e9eef9;
  --prod: #0e7490;       --prod-soft: #e0f2f7;

  /* --- типографика --- */
  --font-sans: 'IBM Plex Sans', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* --- форма и глубина --- */
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 16px;
  --shadow-1: 0 1px 2px rgba(23, 26, 32, .05), 0 1px 4px rgba(23, 26, 32, .04);
  --shadow-2: 0 6px 24px rgba(23, 26, 32, .09), 0 2px 6px rgba(23, 26, 32, .05);
  --shadow-3: 0 12px 40px rgba(23, 26, 32, .18);
  --ring: 0 0 0 3px var(--brand-soft);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { max-width: 1020px; margin: 0 auto; padding: 0 20px; }
.wrap--wide { max-width: 1280px; }

/* ------------------------------------------------------------
   Шапка
   ------------------------------------------------------------ */
header.site {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
header.site .wrap {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 60px; gap: 16px;
}
.logo {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 20px; font-weight: 700; letter-spacing: -.02em;
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.logo::before {
  content: ''; width: 12px; height: 12px; border-radius: 3px;
  background: var(--gold); box-shadow: inset 0 0 0 1.5px rgba(23,26,32,.12);
}
.logo span { color: var(--brand); }

nav.site-nav { display: flex; align-items: center; gap: 4px; }
nav.site-nav a {
  color: var(--ink-2); text-decoration: none; font-size: 15px; font-weight: 500;
  padding: 8px 12px; border-radius: var(--r-s);
  transition: color .15s, background-color .15s;
}
nav.site-nav a:hover { color: var(--ink); background: var(--surface-2); }
nav.site-nav a.active { color: var(--brand); background: var(--brand-soft); }
nav.site-nav a.nav-cta {
  color: var(--brand-ink); background: var(--brand); margin-left: 6px;
}
nav.site-nav a.nav-cta:hover { background: var(--brand-strong); color: var(--brand-ink); }

.nav-toggle {
  display: none; border: 0; background: none; cursor: pointer;
  padding: 10px; margin: -10px; color: var(--ink);
}
.nav-toggle svg { display: block; }

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  nav.site-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: 8px 12px 14px; box-shadow: var(--shadow-2);
  }
  header.site.nav-open nav.site-nav { display: flex; }
  nav.site-nav a { padding: 12px 14px; font-size: 16px; }
  nav.site-nav a.nav-cta { margin-left: 0; text-align: center; }
}

/* ------------------------------------------------------------
   Каркас страницы, типографика
   ------------------------------------------------------------ */
main { padding: 36px 0 72px; }
@media (max-width: 640px) { main { padding: 24px 0 56px; } }

h1 { font-size: 30px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; margin: 0 0 8px; text-wrap: balance; }
h2 { font-size: 19px; line-height: 1.3; font-weight: 600; letter-spacing: -.01em; margin: 30px 0 12px; }
h3 { font-size: 16px; font-weight: 600; margin: 20px 0 8px; }
@media (max-width: 640px) { h1 { font-size: 24px; } }

p { margin: 0 0 12px; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand-strong); }

.sub { color: var(--ink-2); font-size: 16.5px; margin: 0 0 26px; max-width: 60ch; }
.muted { color: var(--ink-3); font-size: 14px; }
.kicker {
  display: block; font-size: 12px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3); margin: 0 0 6px;
}
.mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; }
.error { color: var(--err); font-size: 14.5px; }
.ok { color: var(--ok); font-size: 14.5px; }

.backlink {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--ink-3); text-decoration: none; margin-bottom: 14px;
}
.backlink:hover { color: var(--brand); }

/* ------------------------------------------------------------
   Панели и сетки
   ------------------------------------------------------------ */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-m); box-shadow: var(--shadow-1);
  padding: 26px 28px; margin-bottom: 20px;
}
@media (max-width: 640px) { .panel { padding: 18px 16px; border-radius: var(--r-s); } }
.panel > h2:first-child, .panel > .kicker:first-child { margin-top: 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid2 > * { min-width: 0; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }

.split { display: grid; grid-template-columns: minmax(280px, 5fr) 7fr; gap: 20px; align-items: start; }
.split > * { min-width: 0; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1 1 220px; }
.row > .btn { flex: 0 0 auto; align-self: flex-end; }

.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ------------------------------------------------------------
   Формы
   ------------------------------------------------------------ */
label { display: block; font-size: 13.5px; font-weight: 500; color: var(--ink-2); margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password],
select, textarea {
  width: 100%; height: 44px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-s);
  background: var(--surface); font: inherit; font-size: 16px; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 70px; }
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23565e6a' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--ring);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--brand); box-shadow: var(--ring);
}
.hint { font-size: 13px; color: var(--ink-3); margin: 5px 0 0; }

/* поле с автокомплитом: подсказки поверх контента */
.field-ac { position: relative; }
ul.autocomplete {
  list-style: none; margin: 4px 0 0; padding: 6px;
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-s); box-shadow: var(--shadow-2);
  max-height: 260px; overflow-y: auto;
}
ul.autocomplete li { padding: 9px 10px; cursor: pointer; border-radius: 4px; font-size: 15px; }
ul.autocomplete li:hover { background: var(--brand-soft); color: var(--brand-strong); }

/* ------------------------------------------------------------
   Кнопки
   ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 22px;
  background: var(--brand); color: var(--brand-ink);
  border: 1px solid transparent; border-radius: var(--r-s);
  font: 600 15px/1 var(--font-sans); letter-spacing: .01em;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, transform .06s, box-shadow .15s;
}
.btn:hover { background: var(--brand-strong); color: var(--brand-ink); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--surface); color: var(--ink);
  border-color: var(--line-2);
}
.btn-secondary:hover { background: var(--surface); border-color: var(--brand); color: var(--brand); }

.btn-ghost { background: transparent; color: var(--brand); border-color: transparent; }
.btn-ghost:hover { background: var(--brand-soft); color: var(--brand-strong); }

.btn-danger { background: var(--surface); color: var(--err); border-color: var(--line-2); }
.btn-danger:hover { border-color: var(--err); background: var(--err-soft); color: var(--err); }

.btn-sm { height: 34px; padding: 0 14px; font-size: 13.5px; }
.btn-lg { height: 52px; padding: 0 28px; font-size: 16px; }

/* ------------------------------------------------------------
   Бейджи статусов
   ------------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 11px; border-radius: 999px;
  font-size: 13px; font-weight: 500; line-height: 1.5;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid transparent;
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: 0 0 auto; }
.badge-lg { padding: 7px 16px; font-size: 15px; font-weight: 600; }
.badge-lg::before { width: 9px; height: 9px; }

.badge-ok      { background: var(--ok-soft);   color: var(--ok); }      .badge-ok::before      { background: var(--ok); }
.badge-warn    { background: var(--warn-soft); color: var(--warn); }    .badge-warn::before    { background: var(--warn); }
.badge-err     { background: var(--err-soft);  color: var(--err); }     .badge-err::before     { background: var(--err); }
.badge-info    { background: var(--info-soft); color: var(--info); }    .badge-info::before    { background: var(--info); }
.badge-prod    { background: var(--prod-soft); color: var(--prod); }    .badge-prod::before    { background: var(--prod); }
.badge-neutral { background: var(--surface-2); color: var(--ink-2); }

/* флажки распознавания полей */
.field-flag {
  display: inline-block; font-size: 11.5px; font-weight: 600; letter-spacing: .03em;
  padding: 1px 8px; margin-left: 6px; border-radius: 999px; vertical-align: 1px;
}
.field-flag.ai { background: var(--ok-soft); color: var(--ok); }
.field-flag.manual { background: var(--warn-soft); color: var(--warn); }

/* ------------------------------------------------------------
   Таблицы
   ------------------------------------------------------------ */
table.props { border-collapse: collapse; width: 100%; font-size: 15px; }
table.props td { border-bottom: 1px solid var(--line); padding: 9px 4px; vertical-align: top; }
table.props tr:last-child td { border-bottom: 0; }
table.props td:first-child { color: var(--ink-3); width: 42%; font-size: 14px; padding-right: 12px; }

table.list { border-collapse: collapse; width: 100%; font-size: 14.5px; }
table.list th {
  text-align: left; padding: 8px 10px;
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); border-bottom: 1px solid var(--line-2); white-space: nowrap;
}
table.list td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tbody tr { transition: background-color .12s; }
table.list tbody tr:hover { background: var(--surface-2); }
table.list td.num, table.list th.num { font-variant-numeric: tabular-nums; }

/* мобильный режим: таблица -> карточки (нужны data-label на td) */
@media (max-width: 640px) {
  table.list.collapsible thead { display: none; }
  table.list.collapsible, table.list.collapsible tbody,
  table.list.collapsible tr, table.list.collapsible td { display: block; width: 100%; }
  table.list.collapsible tr {
    border: 1px solid var(--line); border-radius: var(--r-s);
    margin-bottom: 10px; padding: 6px 0; background: var(--surface);
  }
  table.list.collapsible td { border: 0; padding: 6px 14px; }
  table.list.collapsible td[data-label]::before {
    content: attr(data-label);
    display: block; font-size: 11.5px; font-weight: 600; letter-spacing: .05em;
    text-transform: uppercase; color: var(--ink-3); margin-bottom: 1px;
  }
}

/* ------------------------------------------------------------
   Шаги воронки
   ------------------------------------------------------------ */
ol.steps {
  display: flex; gap: 4px; list-style: none; margin: 0 0 26px; padding: 0;
  font-size: 13.5px; font-weight: 500; color: var(--ink-3); flex-wrap: wrap;
}
ol.steps li { display: inline-flex; align-items: center; gap: 8px; }
ol.steps li + li::before {
  content: ''; width: 26px; height: 1px; background: var(--line-2); margin: 0 10px;
}
ol.steps li span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-2); color: var(--ink-3); font-size: 12.5px; font-weight: 600;
}
ol.steps li.active { color: var(--ink); font-weight: 600; }
ol.steps li.active span { background: var(--brand); color: var(--brand-ink); }
ol.steps li.done { color: var(--ink-2); }
ol.steps li.done span { background: var(--ok-soft); color: var(--ok); }
@media (max-width: 640px) {
  ol.steps { font-size: 12.5px; }
  ol.steps li + li::before { width: 12px; margin: 0 6px; }
}

/* ------------------------------------------------------------
   Прогресс, дропзона, пустые состояния
   ------------------------------------------------------------ */
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > div {
  height: 100%; background: var(--brand); border-radius: 999px;
  transition: width .4s ease-out;
  background-image: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  background-size: 200% 100%;
  animation: progress-sheen 1.6s linear infinite;
}
@keyframes progress-sheen { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 1.5px dashed var(--line-2); border-radius: var(--r-m);
  padding: 44px 24px; text-align: center; background: var(--surface);
  cursor: pointer; font-size: 16px; font-weight: 500;
  transition: border-color .15s, background-color .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone svg { color: var(--brand); margin-bottom: 6px; }

.empty { padding: 30px 16px; text-align: center; color: var(--ink-3); font-size: 15px; }

.alert { border-radius: var(--r-s); padding: 12px 14px; font-size: 14.5px; margin: 12px 0; }
.alert-err { background: var(--err-soft); color: var(--err); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }

/* ------------------------------------------------------------
   Превью макета: обложка, лента страниц, лайтбокс
   ------------------------------------------------------------ */
.cover-preview {
  max-width: 100%; border: 1px solid var(--line); border-radius: 4px;
  box-shadow: var(--shadow-2); cursor: zoom-in;
  transition: transform .15s, box-shadow .15s;
}
.cover-preview:hover { transform: translateY(-2px); box-shadow: var(--shadow-3); }

.pages-preview {
  display: flex; gap: 10px; overflow-x: auto; padding: 8px 2px 12px;
  scroll-snap-type: x proximity; scrollbar-width: thin;
}
.pages-preview img {
  height: 190px; border: 1px solid var(--line); border-radius: 4px;
  cursor: zoom-in; scroll-snap-align: start; flex: 0 0 auto;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  background: var(--surface);
}
.pages-preview img:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--brand); }
@media (max-width: 640px) { .pages-preview img { height: 150px; } }

.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(13, 15, 19, .93); text-align: center;
}
.lightbox__body { position: absolute; inset: 58px 72px 44px; overflow: auto; }
.lightbox__body img { max-width: 100%; border-radius: 3px; box-shadow: 0 8px 48px rgba(0,0,0,.6); }
.lb-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255, 255, 255, .12); color: #fff; border: 0;
  font-size: 18px; cursor: pointer; transition: background-color .15s;
}
.lb-btn:hover { background: rgba(255, 255, 255, .24); }
.lb-close { position: absolute; top: 12px; right: 14px; }
.lb-prev { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); }
.lb-next { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); }
.lb-counter { position: absolute; bottom: 12px; left: 0; right: 0; color: #b9c0cb; font-size: 13.5px; }
@media (max-width: 640px) {
  .lightbox__body { inset: 56px 10px 82px; }
  .lb-prev { left: auto; right: 74px; top: auto; bottom: 26px; transform: none; }
  .lb-next { top: auto; bottom: 26px; transform: none; }
  .lb-counter { bottom: 78px; }
}

/* ------------------------------------------------------------
   Таймлайн истории (адмінка, статус замовлення)
   ------------------------------------------------------------ */
ul.timeline { list-style: none; margin: 0; padding: 0 0 0 22px; position: relative; }
ul.timeline::before {
  content: ''; position: absolute; left: 5px; top: 8px; bottom: 8px;
  width: 2px; background: var(--line);
}
ul.timeline li { position: relative; padding: 0 0 18px; }
ul.timeline li:last-child { padding-bottom: 0; }
ul.timeline li::before {
  content: ''; position: absolute; left: -22px; top: 6px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--brand);
}
ul.timeline li.tl-muted::before { border-color: var(--line-2); }
.tl-date { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-3); }
.tl-title { font-size: 14.5px; font-weight: 600; }
.tl-note { font-size: 14px; color: var(--ink-2); }

/* ------------------------------------------------------------
   Адмінка
   ------------------------------------------------------------ */
.admin-tabs {
  display: flex; gap: 2px; margin: 0 0 22px; padding: 4px;
  background: var(--surface-2); border-radius: var(--r-m);
  overflow-x: auto; scrollbar-width: none;
}
.admin-tabs a {
  flex: 0 0 auto; padding: 8px 16px; border-radius: var(--r-s);
  color: var(--ink-2); text-decoration: none; font-size: 14.5px; font-weight: 500;
  white-space: nowrap; transition: color .15s, background-color .15s;
}
.admin-tabs a:hover { color: var(--ink); }
.admin-tabs a.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); font-weight: 600; }
.admin-tabs .tabs-note { margin-left: auto; align-self: center; padding: 0 10px; white-space: nowrap; }
@media (max-width: 760px) { .admin-tabs .tabs-note { display: none; } }

.status-hero {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 0 0 6px;
}
.status-hero h1 { margin: 0; font-family: var(--font-mono); letter-spacing: 0; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > .actions { align-self: flex-end; min-height: 44px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters select { width: auto; min-width: 170px; }
.filters input[type=text] { flex: 1 1 200px; width: auto; }

.pager { display: flex; gap: 12px; align-items: center; margin-top: 16px; }

/* ------------------------------------------------------------
   Подвал
   ------------------------------------------------------------ */
footer.site { border-top: 1px solid var(--line); padding: 26px 0 34px; background: var(--surface); }
footer.site .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: baseline; }
footer.site nav { display: flex; gap: 18px; flex-wrap: wrap; }
footer.site a { color: var(--ink-2); font-size: 14px; text-decoration: none; }
footer.site a:hover { color: var(--brand); }
footer.site .copy { color: var(--ink-3); font-size: 13px; }

/* ------------------------------------------------------------
   Доступность и движение
   ------------------------------------------------------------ */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--surface); color: var(--brand); padding: 10px 16px;
  border-radius: 0 0 var(--r-s) 0; box-shadow: var(--shadow-2);
}
.skip-link:focus { left: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
