:root {
  --ink: #1c1814;
  --muted: #5c564e;
  --rule: #d4cdc2;
  --paper: #f3eee4;
  --sheet: #fffcf7;
  --accent: #6e3f2d;
  --stamp: #2f4a3c;
  --mark: #f0e2c4;
}

.file-warn {
  font-family: system-ui, sans-serif;
  font-size: 14px;
  padding: 12px 20px;
  background: var(--accent);
  color: var(--sheet);
}
.file-warn a { color: inherit; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.35;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 20px;
  background: rgba(243, 238, 228, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.toolbar p {
  margin: 0 auto 0 0;
  font-size: 14px;
  color: var(--muted);
}
.toolbar button,
.toolbar a.btn,
.toolbar label.btn,
.editor button,
.card-actions button {
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--sheet);
  cursor: pointer;
}
.toolbar button.ghost,
.editor button.ghost,
.card-actions button.ghost {
  background: transparent;
  color: var(--ink);
}
.toolbar button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.toolbar label.btn {
  display: inline-block;
  background: transparent;
  color: var(--ink);
}
.toolbar a.btn {
  text-decoration: none;
  display: inline-block;
}
.toolbar input[type="file"] { display: none; }
.pdf-page {
  margin: 0;
  padding: 0;
  max-width: none;
}
.pdf-frame {
  display: block;
  width: 100%;
  height: calc(100vh - 56px);
  border: 0;
  background: #525252;
}

.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.page {
  background: var(--sheet);
  border: 1px solid var(--rule);
  padding: 14mm 15mm 12mm;
  margin: 0 auto 28px;
  width: 210mm;
  min-height: 297mm;
  box-shadow: 0 12px 32px rgba(28, 24, 20, 0.08);
}

header.mast {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 10px;
  margin-bottom: 16px;
}
.eyebrow {
  font-family: system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 4px;
}
h1 {
  font-size: 26px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.02em;
}
.stamp {
  flex: none;
  border: 1.5px solid var(--stamp);
  color: var(--stamp);
  font-family: system-ui, sans-serif;
  font-size: 12px;
  line-height: 1.3;
  padding: 8px 10px;
  text-align: right;
}

h2 {
  font-size: 13px;
  font-family: system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 18px 0 8px;
  color: var(--accent);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-family: system-ui, sans-serif;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 8px;
}

.shop {
  columns: 2;
  column-gap: 28px;
}
.shop .group { break-inside: avoid; }
ul { list-style: none; margin: 0; padding: 0; }
.item {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) max-content;
  gap: 8px 10px;
  align-items: baseline;
  padding: 3px 0;
  border-bottom: 1px dotted var(--rule);
  font-size: 14px;
}
.item.plain { grid-template-columns: 1fr auto; }
.box {
  width: 11px;
  height: 11px;
  border: 1.25px solid var(--ink);
  margin-top: 3px;
}
.qty {
  font-family: system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  white-space: nowrap;
  justify-self: end;
  padding-left: 6px;
}

.split {
  display: grid;
  grid-template-columns: 0.92fr 1.18fr;
  gap: 18px;
  align-items: start;
}
.call {
  background: var(--mark);
  border: 1px solid #e0d3b0;
  padding: 7px 10px;
  font-family: system-ui, sans-serif;
  font-size: 13px;
  margin: 6px 0 10px;
}
.steps { counter-reset: step; margin: 0; padding: 0; }
.steps li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  margin: 0 0 5px;
  font-size: 13px;
}
.steps li > span { min-width: 0; }
.steps b { white-space: nowrap; }
.steps li::before {
  counter-increment: step;
  content: counter(step);
  font-family: system-ui, sans-serif;
  font-size: 11px;
  width: 22px;
  height: 22px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.note {
  border-top: 1px solid var(--ink);
  margin-top: 10px;
  padding-top: 8px;
  font-size: 12.5px;
}
.lined { margin-top: 8px; }
.lined p {
  margin: 0;
  border-bottom: 1px solid var(--rule);
  height: 28px;
}
.source {
  margin-top: 10px;
  font-family: system-ui, sans-serif;
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
}

.cards { display: grid; gap: 12px; }
.card {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--sheet);
  border: 1px solid var(--rule);
  padding: 16px 18px;
}
.card.has-photo {
  grid-template-columns: 28px 72px 1fr auto;
}
.card-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border: 1px solid var(--rule);
  background: #ebe4d6;
}
.hero-photo {
  width: 100%;
  height: 168px;
  object-fit: cover;
  border: 1px solid var(--rule);
  margin: 0 0 12px;
  background: #ebe4d6;
}
.photo-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.photo-preview {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border: 1px solid var(--rule);
  background: #ebe4d6;
}
.photo-edit label.btn {
  display: inline-block;
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.photo-edit input[type="file"] { display: none; }
.card h3 { margin: 0 0 4px; font-size: 20px; }
.card .sub {
  font-family: system-ui, sans-serif;
  font-size: 13px;
  color: var(--muted);
}
.card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--ink);
}
.card-actions { display: flex; gap: 8px; }
.empty {
  color: var(--muted);
  font-size: 15px;
}

.editor {
  background: var(--sheet);
  border: 1px solid var(--rule);
  padding: 22px 24px 32px;
}
.editor h1 { margin-bottom: 16px; }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-family: system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  font: inherit;
  font-size: 15px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  background: #fff;
  color: var(--ink);
}
.field textarea { min-height: 72px; resize: vertical; }
.ing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ing-table th {
  font-family: system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  padding: 4px 4px 6px;
}
.ing-table td { padding: 3px; vertical-align: middle; }
.ing-table input,
.ing-table select {
  width: 100%;
  font: inherit;
  font-size: 13px;
  padding: 6px 7px;
  border: 1px solid var(--rule);
  background: #fff;
}
.ing-table .col-amt { width: 72px; }
.ing-table .col-unit { width: 110px; }
.ing-table .col-aisle { width: 150px; }
.ing-table .col-del { width: 36px; }
.ing-table .del {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.row-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.danger { background: transparent !important; color: var(--accent) !important; }

@media print {
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    background: white;
  }
  .toolbar, .no-print { display: none !important; }
  .wrap { padding: 0; max-width: none; margin: 0; }

  .print-sheet {
    width: 210mm;
    height: 296mm;
    overflow: hidden;
    margin: 0 auto;
    page-break-after: auto;
    break-after: auto;
  }
  .pages .print-sheet:not(:last-child) {
    break-after: page;
    page-break-after: always;
  }

  .kitchen-page {
    width: 210mm;
    min-height: 0;
    margin: 0;
    border: 0;
    box-shadow: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .page.shop-page {
    width: auto;
    min-height: 0;
    border: 0;
    box-shadow: none;
    margin: 0;
    padding: 12mm 18mm 12mm 12mm;
    break-inside: auto;
    page-break-inside: auto;
  }
  .shop-page .shop {
    columns: unset;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 18px;
    row-gap: 4px;
    align-items: start;
  }
  .shop-page .group { min-width: 0; }
  .shop-page .item > span:nth-child(2) { overflow-wrap: anywhere; }

  @page { size: A4; margin: 0; }
}

html.print-fit .toolbar,
html.print-fit .no-print { display: none !important; }
html.print-fit .wrap { padding: 0; max-width: none; }

/* Снимок: вся карточка, без обрезки под 297мм */
.kitchen-snap-host {
  position: fixed;
  left: -12000px;
  top: 0;
  box-sizing: border-box;
  width: 210mm;
  height: auto;
  padding: 0;
  overflow: visible;
  background: #fffcf7;
  pointer-events: none;
}
html.kitchen-snap .kitchen-snap-host .kitchen-page {
  width: 100% !important;
  min-height: 0 !important;
  height: auto !important;
  margin: 0 !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 12mm 16mm 12mm !important;
}
html.kitchen-snap .kitchen-snap-host .split {
  display: grid !important;
  grid-template-columns: 0.92fr 1.18fr !important;
}

@media screen and (max-width: 860px) {
  .page { width: auto; min-height: 0; padding: 22px; }
  .shop, .split, .grid-2, .card, .card.has-photo {
    columns: 1;
    grid-template-columns: 1fr;
  }
  .card, .card.has-photo { grid-template-columns: 28px 1fr; }
  .card-thumb { grid-column: 2; width: 100%; height: 140px; }
  .card-actions { grid-column: 2; }
  .hero-photo { height: 140px; }
}
