:root {
  color-scheme: light;
  --bg: #f6f5f0;
  --surface: #ffffff;
  --surface-soft: #fbfaf6;
  --ink: #25231f;
  --muted: #6f6a61;
  --line: #ddd8cd;
  --accent: #2f6f56;
  --accent-dark: #20513e;
  --danger: #a33a2d;
  --danger-bg: #fff0ed;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a { color: var(--accent-dark); }

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  min-height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  position: sticky;
  top: 0;
  z-index: 2;
}

.brand {
  font-weight: 800;
  text-decoration: none;
  color: var(--ink);
}

nav, .userbar, .actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

nav a, .userbar a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 650;
}

main {
  width: min(1280px, calc(100% - 32px));
  margin: 28px auto 56px;
  display: grid;
  gap: 18px;
}

.hero {
  padding: 28px 0 8px;
}

h1, h2 {
  margin: 0;
  line-height: 1.15;
}

h1 { font-size: 34px; }
h2 { font-size: 20px; }
p { color: var(--muted); }

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

.panel, .auth-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 10px 25px rgba(40, 34, 24, 0.06);
}

.auth-panel {
  width: min(440px, 100%);
  margin: 10vh auto 0;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metric strong {
  display: block;
  font-size: 28px;
}

.metric span, .muted {
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td { border-bottom: 0; }
.num { text-align: right; }

.procedure-text {
  display: inline-block;
  background: #fff36d;
  color: #25231f;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}

.recipe-print-page {
  background: #fff;
}

.recipe-print-page.layout-1 {
  width: 210mm;
  min-height: 297mm;
  padding: 20mm 18mm 18mm 48mm;
}

.recipe-print-page.layout-2 {
  width: 71mm;
  min-height: 147mm;
  padding: 8mm 4mm 4mm;
}

.recipe-print-logo {
  display: block;
  width: 42mm;
  max-height: 22mm;
  object-fit: contain;
  margin: 0 0 8mm;
}

.recipe-print-page.layout-2 .recipe-print-logo {
  display: none;
}

.recipe-print-page h1 {
  font-size: 18pt;
  margin-bottom: 3mm;
}

.recipe-print-page.layout-2 h1 {
  font-size: 14pt;
  margin-bottom: 2mm;
}

.recipe-print-comment {
  color: var(--ink);
  font-weight: 800;
  font-size: 11pt;
  margin: 0 0 2mm;
  white-space: pre-wrap;
}

.recipe-print-page.layout-2 .recipe-print-comment {
  font-size: 9pt;
}

.recipe-print-total {
  color: var(--ink);
  font-weight: 800;
  font-size: 13pt;
  margin: 0 0 3mm;
}

.recipe-print-page.layout-2 .recipe-print-total {
  font-size: 8pt;
  margin-bottom: 2mm;
}

.recipe-print-page table {
  border-collapse: collapse;
  font-size: 11pt;
}

.recipe-print-page th,
.recipe-print-page td {
  border-bottom: 1px solid #e0e0e0;
  color: #000;
  font-weight: 800;
  padding: 4px;
}

.recipe-print-page th {
  border-bottom-color: #999;
  color: #000;
  font-size: 13pt;
  text-transform: none;
}

.recipe-print-page td:last-child,
.recipe-print-page th:last-child {
  text-align: right;
  width: 32mm;
}

.recipe-print-page .procedure-row td {
  background: #fff36d;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  font-size: 13pt;
}

.recipe-print-page.layout-2 table {
  font-size: 8pt;
}

.recipe-print-page.layout-2 th,
.recipe-print-page.layout-2 td {
  padding: 2px;
}

.recipe-print-page.layout-2 th {
  font-size: 9pt;
}

.recipe-print-page.layout-2 .ingredient-row td {
  font-weight: 400;
}

.recipe-print-page.layout-2 .procedure-row td {
  background: #fff36d;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  font-size: 8pt;
}

.scale-label {
  font-size: 0.8em;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.grid-form.compact {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  color: var(--muted);
  font-size: 13px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  padding: 9px 10px;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.wide { grid-column: 1 / -1; }
.check { align-content: end; }
.check input { width: auto; }

.field-warning {
  border: 1px solid #e5b454;
  background: #fff7db;
  color: #74520a;
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 700;
}

button, .button {
  appearance: none;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  text-decoration: none;
  font: inherit;
  font-weight: 750;
}

.secondary {
  background: #e9e5db;
  color: var(--ink);
}

.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.inline {
  display: inline-flex;
  margin: 0;
}

.qr-preview {
  width: 96px;
  height: 96px;
  object-fit: contain;
  display: block;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.admin-logo-row {
  display: grid;
  grid-template-columns: minmax(180px, 320px) 1fr;
  gap: 16px;
  align-items: end;
}

.admin-logo-preview {
  width: 100%;
  max-height: 120px;
  object-fit: contain;
  display: block;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.alert {
  border-radius: 6px;
  padding: 10px 12px;
}

.error {
  background: var(--danger-bg);
  color: var(--danger);
}

.filters {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

.filters input {
  width: auto;
  min-width: 90px;
}

.filters input[type="date"],
.filters input[type="search"],
.filters input[name="q"] {
  min-width: 170px;
}

.toolbar, .button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.confirm-copy {
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.weekly-header .filters {
  margin-top: 14px;
}

#weekly-plan-table th,
#weekly-plan-table td {
  border: 1px solid var(--line);
}

#weekly-plan-table .product {
  min-width: 150px;
  font-weight: 800;
}

#weekly-plan-table tfoot th,
#weekly-plan-table tfoot td {
  background: #eef4ed;
  font-weight: 800;
  border-top: 3px solid #a4b79d;
}

.mobile-day-controls {
  display: none;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 10px 0;
}

.mobile-day-controls select {
  width: auto;
  min-width: 140px;
}

.booking-calendar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.booking-calendar-month {
  display: grid;
  gap: 8px;
}

.booking-calendar-month h3 {
  margin: 0;
  font-size: 16px;
}

.booking-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.booking-calendar-weekday {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.booking-calendar-day {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 3px;
  padding: 5px 2px;
  text-decoration: none;
}

.booking-calendar-day.open {
  background: #e8f4ec;
  border-color: #8fbaa0;
  color: var(--accent-dark);
  font-weight: 850;
}

.booking-calendar-day.booked {
  background: #fff2cf;
  border-color: #d79d35;
  color: #73510d;
}

.booking-calendar-day.open.booked {
  background: linear-gradient(135deg, #e8f4ec 0%, #e8f4ec 52%, #fff2cf 52%, #fff2cf 100%);
  border-color: #d79d35;
}

.booking-calendar-day.selected {
  outline: 3px solid #d8a33b;
  outline-offset: 1px;
}

.booking-calendar-day.outside {
  visibility: hidden;
}

.booking-calendar-badges {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: center;
}

.booking-calendar-badges span {
  min-width: 16px;
  min-height: 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
}

.booking-calendar-count {
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
}

.label-sheet {
  width: 210mm;
  height: 297mm;
  margin: 0 auto;
  background: #fff;
  display: grid;
  grid-template-columns: repeat(3, 70mm);
  grid-template-rows: repeat(7, 42.4286mm);
  grid-auto-rows: 42.4286mm;
  align-content: start;
  justify-content: start;
  padding: var(--page-shift-y, 0) 0 0 var(--page-shift-x, 0);
  overflow: hidden;
}

.product-label {
  position: relative;
  width: 70mm;
  height: 42.4286mm;
  overflow: hidden;
  background: #fff;
  break-inside: avoid;
  page-break-inside: avoid;
  color: #1f1b16;
}

.label-inner {
  position: absolute;
  left: 13.8mm;
  top: -13.8mm;
  width: 42.4mm;
  height: 70mm;
  transform: rotate(90deg);
  transform-origin: 21.2mm 35mm;
  font-family: "American Typewriter", "Courier New", serif;
  color: #1f1b16;
}

.label-logo {
  position: absolute;
  left: calc(8.2mm + var(--logo-shift-x, 0mm));
  top: calc(4.8mm + var(--logo-shift-y, 0mm));
  width: 26mm;
  max-height: 11mm;
  object-fit: contain;
}

.label-inner h2 {
  position: absolute;
  left: calc(3mm + var(--text-shift-x, 0mm));
  top: calc(15mm + var(--text-shift-y, 0mm));
  width: 36.4mm;
  margin: 0;
  text-align: center;
  font-family: Chalkduster, "Comic Sans MS", cursive;
  font-size: 10pt;
  line-height: 1.05;
}

.label-inner h3 {
  position: absolute;
  left: calc(3mm + var(--text-shift-x, 0mm));
  top: calc(25mm + var(--text-shift-y, 0mm));
  width: 36.4mm;
  margin: 0;
  font-size: 8pt;
  line-height: 1.1;
}

.label-inner p {
  position: absolute;
  left: calc(3mm + var(--text-shift-x, 0mm));
  top: calc(28.8mm + var(--text-shift-y, 0mm));
  width: 36.4mm;
  margin: 0;
  color: #1f1b16;
  font-size: 8pt;
  line-height: 1.18;
  max-height: 31mm;
  overflow: hidden;
}

.label-footer {
  position: absolute;
  left: 3mm;
  bottom: 3mm;
  display: grid;
  gap: 0.4mm;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 7pt;
  line-height: 1.1;
}

.best-before {
  position: absolute;
  right: 5.2mm;
  bottom: 3mm;
  transform: rotate(90deg);
  transform-origin: bottom right;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 7pt;
  font-weight: 800;
}

.spaced {
  margin-top: 14px;
}

.price-print-page {
  min-height: 260mm;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  position: relative;
  padding: 14mm 12mm 10mm;
  page: price-list;
}

.price-print-page .brand-logo {
  position: absolute;
  top: 8mm;
  right: 10mm;
  width: 36mm;
  height: auto;
  object-fit: contain;
}

.price-print-page h2 {
  margin: calc(10mm + 0.2rem) 0 0.5rem;
  text-align: center;
  letter-spacing: 0.06em;
  font-family: "Bradley Hand", "Bradley Hand ITC", "Comic Sans MS", cursive;
  font-size: 78px;
  line-height: 1;
}

.price-print-page table {
  margin-top: 5mm;
}

.price-print-page.without_title table {
  margin-top: calc(10mm + 0.7rem);
}

.price-print-page td {
  padding: 0.5rem 0.4rem;
  font-family: "American Typewriter", "Courier New", serif;
  font-size: 36px;
  line-height: 1.08;
}

.price-print-page td:last-child {
  text-align: right;
  width: 30%;
}

.price-cell {
  white-space: nowrap;
}

.bottom-section {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.price-print-page.without_title .bottom-section {
  margin-top: 0;
  flex: 1;
}

.price-qr-block {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 68mm;
  gap: 8mm;
}

.price-qr-block.text-only {
  min-height: 0;
  justify-content: flex-start;
}

.price-qr-image {
  width: 68mm;
  height: 68mm;
  object-fit: contain;
  border: 0;
  padding: 0;
  background: #fff;
}

.qr-text {
  text-align: left;
  font-family: "American Typewriter", "Courier New", serif;
  font-size: 36px;
  line-height: 1.3;
  max-width: 80mm;
}

.qr-text-title {
  display: block;
  text-align: center;
  font-size: 72px;
  line-height: 1.05;
  margin-bottom: 0.2em;
}

.qr-text-body {
  display: block;
  white-space: pre-wrap;
}

.price-qr-block.text-only .qr-text {
  max-width: none;
  width: 100%;
}

.qr-label {
  text-align: center;
  font-family: "American Typewriter", "Courier New", serif;
  font-size: 0.95rem;
  margin-top: 0.35rem;
}

.contact {
  text-align: center;
  font-family: "American Typewriter", "Courier New", serif;
  font-size: 0.94rem;
  border-top: 1px solid var(--line);
  padding-top: 0.45rem;
}

.price-print-page.without_title .contact {
  margin-top: auto;
}

.content-print-page {
  min-height: 260mm;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  position: relative;
  padding: 14mm 12mm 10mm;
  page: product-contents;
}

.content-print-page .brand-logo {
  position: absolute;
  top: 8mm;
  right: 10mm;
  width: 36mm;
  height: auto;
  object-fit: contain;
}

.content-header {
  padding-right: 42mm;
  margin-top: 2mm;
}

.content-header h1 {
  margin: 0;
  font-family: "Bradley Hand", "Bradley Hand ITC", "Comic Sans MS", cursive;
  font-size: 2rem;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.content-product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  align-content: start;
}

.content-product-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem;
  break-inside: avoid;
  page-break-inside: avoid;
  background: #fff;
}

.content-product-card h2 {
  margin: 0 0 0.5rem;
  font-family: "American Typewriter", "Courier New", serif;
  font-size: 1.35rem;
  line-height: 1.15;
}

.content-product-card strong {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.98rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.content-ingredients,
.content-allergens {
  margin: 0;
  font-family: "American Typewriter", "Courier New", serif;
  font-size: 1rem;
  line-height: 1.35;
}

.content-allergens {
  margin-top: 0.55rem;
}

.content-empty {
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
}

.print-day {
  break-inside: avoid;
  margin-top: 18px;
}

.recipe-print-card {
  break-inside: avoid;
  margin-top: 12px;
}

.recipe-print-card h2 {
  margin-bottom: 3px;
  font-size: 18px;
}

.recipe-meta {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 5px;
}

.recipe-comment {
  color: var(--ink);
  font-size: 12px;
  margin: 0 0 6px;
  white-space: pre-wrap;
}

.weekly-recipes-print table {
  font-size: 12px;
}

.weekly-recipes-print th,
.weekly-recipes-print td {
  padding: 3px 6px;
  line-height: 1.2;
  border-bottom: 1px solid #cfc8bb;
}

.weekly-recipes-print tbody tr:nth-child(even) td {
  background: #fbfaf6;
}

.weekly-recipes-print .weekly-procedure-row td {
  background: #fff36d;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.weekly-recipes-print table th:nth-child(2),
.weekly-recipes-print table th:nth-child(3),
.weekly-recipes-print table td:nth-child(2),
.weekly-recipes-print table td:nth-child(3) {
  text-align: right;
  width: 105px;
}

.weekly-recipes-print {
  page: recipes-portrait;
}

.oven-print table {
  font-size: 11px;
}

.oven-print th,
.oven-print td {
  padding: 4px 6px;
  line-height: 1.15;
  border: 1px solid var(--line);
}

.oven-print th:first-child,
.oven-print td:first-child {
  width: 56px;
  font-weight: 800;
}

.oven-print th:nth-child(2),
.oven-print td:nth-child(2) {
  width: 170px;
  font-size: 15px;
}

.oven-print {
  page: oven-landscape;
}

@media print {
  .topbar, .button, button, .no-print {
    display: none !important;
  }

  body {
    background: #fff;
  }

  main {
    width: 100%;
    margin: 0;
  }

  .panel {
    border: 0;
    box-shadow: none;
  }

  body:has(.price-print-page) main > :not(.price-print-page) {
    display: none !important;
  }

  body:has(.content-print-page) main > :not(.content-print-page) {
    display: none !important;
  }

  body:has(.recipe-print-page) main > :not(.recipe-print-page) {
    display: none !important;
  }

  body:has(.label-sheet) main > :not(.label-sheet) {
    display: none !important;
  }

  body:has(.label-sheet) {
    margin: 0 !important;
    padding: 0 !important;
    width: 210mm;
    height: 297mm;
    overflow: hidden;
  }

  body:has(.label-sheet) main {
    width: 210mm !important;
    height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block;
  }

  .recipe-print-page {
    box-shadow: none;
    border: 0;
    margin: 0 auto;
  }

  .recipe-print-page.layout-1 {
    page: recipe-a4;
    width: auto;
    min-height: auto;
    padding: 20mm 18mm 18mm 48mm;
  }

  .recipe-print-page.layout-2 {
    page: recipe-label;
    width: auto;
    min-height: auto;
    padding: 8mm 4mm 4mm;
  }

  .price-print-page {
    min-height: 260mm;
    margin: 0 auto;
    padding: 14mm 12mm 10mm;
  }

  .content-print-page {
    page: product-contents;
    min-height: 281mm;
    margin: 0 auto;
    padding: 0 10mm;
  }

  .content-product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
  }

  .content-product-card {
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .label-sheet {
    page: labels-a4;
    width: 210mm;
    height: 297mm;
    min-height: 0;
    margin: 0;
    padding: var(--page-shift-y, 0) 0 0 var(--page-shift-x, 0);
    box-shadow: none;
    overflow: hidden;
    break-after: avoid;
    page-break-after: avoid;
  }

  .price-print-page .bottom-section {
    display: flex !important;
    margin-top: auto !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .price-print-page .price-qr-block {
    display: flex !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .price-print-page .qr-text,
  .price-print-page .price-qr-image,
  .price-print-page .qr-label,
  .price-print-page .contact {
    visibility: visible !important;
  }

  .weekly-recipes-print {
    justify-self: center;
    width: 170mm !important;
    max-width: 170mm !important;
    margin-left: 35mm !important;
    margin-right: 0 !important;
    padding: 0 !important;
  }

  @page recipes-portrait {
    size: A4 portrait;
    margin: 10mm;
  }

  @page recipe-a4 {
    size: A4 portrait;
    margin: 0;
  }

  @page recipe-label {
    size: 71mm 147mm;
    margin: 0;
  }

  @page price-list {
    size: A4 portrait;
    margin: 10mm;
  }

  @page product-contents {
    size: A4 portrait;
    margin: 8mm 10mm;
  }

  @page labels-a4 {
    size: A4 portrait;
    margin: 0;
  }

  @page oven-landscape {
    size: A4 landscape;
    margin: 10mm;
  }
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
    padding: 14px 16px;
  }

  main {
    width: min(100% - 20px, 1280px);
    margin-top: 18px;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .mobile-day-controls {
    display: flex;
  }

  .hide-on-mobile {
    display: none;
  }

  .admin-logo-row {
    grid-template-columns: 1fr;
  }

  #weekly-plan-table {
    display: table;
    white-space: normal;
  }
}
