:root {
  color-scheme: light;
  --background: #f3f5f1;
  --surface: #ffffff;
  --surface-soft: #f7f9f6;
  --ink: #18231f;
  --muted: #66736d;
  --line: #dde4de;
  --line-strong: #cbd5ce;
  --accent: #176b5d;
  --accent-hover: #10574c;
  --accent-soft: #e5f1ed;
  --danger: #b4433d;
  --danger-soft: #fff0ee;
  --shadow: 0 10px 35px rgba(28, 48, 39, 0.06);
  --radius: 16px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(199, 219, 203, 0.24), transparent 27rem),
    var(--background);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button, input[type="checkbox"] { cursor: pointer; }
button { color: inherit; }
textarea { resize: vertical; }
input, textarea { color: var(--ink); }
input::placeholder, textarea::placeholder { color: #9aa49f; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(23, 107, 93, 0.22);
  outline-offset: 2px;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-header {
  height: 74px;
  padding: 0 max(28px, calc((100vw - 1380px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: rgba(255, 255, 255, 0.83);
  border-bottom: 1px solid rgba(207, 218, 210, 0.8);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--ink);
}
.brand-mark {
  width: 35px;
  height: 35px;
  padding: 6px;
  border-radius: 9px;
  background: var(--accent);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 2px;
}
.brand-mark span { background: #fff; border-radius: 1px; }
.brand-mark span:nth-child(1) { grid-area: 1 / 1 / 3 / 3; border: 2px solid #fff; background: transparent; }
.brand-mark span:nth-child(2) { grid-area: 1 / 4; }
.brand-mark span:nth-child(3) { grid-area: 2 / 4; }
.brand-mark span:nth-child(4) { grid-area: 3 / 1; }
.brand-mark span:nth-child(5) { grid-area: 3 / 3 / 5 / 5; border: 2px solid #fff; background: transparent; }
.brand-mark span:nth-child(6) { grid-area: 4 / 1; }
.brand-mark span:nth-child(7) { grid-area: 3 / 2; }
.brand-name { font-size: 20px; font-weight: 750; letter-spacing: -0.5px; }
.brand-tag {
  margin-left: 2px;
  padding: 4px 8px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0.9px;
}
.header-actions { display: flex; align-items: center; gap: 18px; }
.privacy-note { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.privacy-note svg { width: 14px; height: 14px; }
.lang-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}
.lang-button {
  min-width: 32px;
  height: 26px;
  padding: 0 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.lang-button:hover { color: var(--accent); }
.lang-button[aria-pressed="true"] { background: #fff; color: var(--accent); box-shadow: 0 1px 3px rgba(28, 48, 39, 0.14); }
.lang-button:focus-visible { outline: 3px solid rgba(23, 107, 93, 0.22); outline-offset: 1px; }

.app-shell { max-width: 1380px; margin: 0 auto; padding: 42px 28px 56px; }
.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 31px; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  line-height: 1.4;
  font-weight: 800;
  letter-spacing: 1.3px;
  text-transform: uppercase;
}
h1 { margin: 0; font-size: clamp(30px, 3.15vw, 43px); line-height: 1.1; letter-spacing: -1.65px; font-weight: 730; }
.intro-copy { max-width: 660px; margin: 13px 0 0; color: var(--muted); font-size: 15px; line-height: 1.65; }
.local-save-note { display: flex; align-items: center; gap: 8px; padding-bottom: 4px; white-space: nowrap; color: var(--muted); font-size: 11px; }
.save-dot { width: 7px; height: 7px; border-radius: 50%; background: #58a484; box-shadow: 0 0 0 4px rgba(88, 164, 132, 0.12); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(420px, 0.94fr); align-items: start; gap: 28px; }
.editor-column { min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.input-panel { padding: 25px; }
.section-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  margin-top: 1px;
}
h2 { margin: 0; font-size: 17px; line-height: 1.45; font-weight: 700; letter-spacing: -0.25px; }
.section-heading p { margin: 3px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.bulk-input {
  display: block;
  width: 100%;
  min-height: 124px;
  padding: 14px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-soft);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.bulk-input:focus { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23, 107, 93, 0.06); }
.input-options { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 16px 0 19px; }
.checkbox-label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; cursor: pointer; }
.checkbox-label input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.compact-field { display: inline-flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.unit-input { display: inline-flex; align-items: center; position: relative; }
.unit-input input { padding-right: 35px !important; }
.unit-input > span { position: absolute; right: 11px; color: var(--muted); font-size: 11px; pointer-events: none; }
.compact-field input { width: 76px; height: 34px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 5px 8px; font-size: 12px; background: #fff; }
.field-hint { margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 10px; line-height: 1.45; }

.button {
  min-height: 40px;
  padding: 9px 15px;
  border: 0;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 12px;
  font-weight: 700;
  transition: background 0.15s, transform 0.15s, opacity 0.15s, box-shadow 0.15s;
}
.button:not(:disabled):active { transform: translateY(1px); }
.button-primary { color: #fff; background: var(--accent); box-shadow: 0 3px 10px rgba(23, 107, 93, 0.14); }
.button-primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 0 4px 14px rgba(23, 107, 93, 0.2); }
.button-primary:disabled { cursor: not-allowed; opacity: 0.45; box-shadow: none; }
.button-full { width: 100%; }
.button-quiet { background: var(--accent-soft); color: var(--accent); }
.button-quiet:hover { background: #d8e9e2; }
.text-button {
  padding: 3px 0;
  border: 0;
  background: none;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 650;
}
.text-button:hover { color: var(--accent-hover); text-decoration: underline; }
.text-button svg { width: 14px; height: 14px; }
.icon-button {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: #fff;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-button:hover:not(:disabled) { background: var(--surface-soft); color: var(--accent); border-color: var(--line-strong); }
.icon-button:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-button svg { width: 17px; height: 17px; }

.items-section { margin-top: 29px; }
.items-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 13px; padding: 0 2px; }
.title-with-count { display: flex; align-items: center; gap: 10px; }
.title-with-count .step-number { margin: 0; }
.count-badge { min-width: 22px; padding: 2px 6px; text-align: center; border: 1px solid var(--line-strong); border-radius: 20px; color: var(--muted); font-size: 10px; font-weight: 700; }
.empty-state { padding: 37px 25px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: rgba(255, 255, 255, 0.45); }
.empty-state h3 { margin: 15px 0 6px; font-size: 14px; font-weight: 650; }
.empty-state p { max-width: 320px; margin: 0 auto; color: var(--muted); font-size: 11px; line-height: 1.6; }
.empty-qr { width: 50px; height: 50px; margin: 0 auto; display: grid; grid-template: repeat(4, 1fr) / repeat(4, 1fr); gap: 3px; opacity: 0.45; }
.empty-qr span { background: #90a199; border-radius: 2px; }
.empty-qr span:nth-child(1) { grid-area: 1 / 1 / 3 / 3; background: transparent; border: 4px solid #90a199; }
.empty-qr span:nth-child(2) { grid-area: 1 / 4; }
.empty-qr span:nth-child(3) { grid-area: 2 / 4; }
.empty-qr span:nth-child(4) { grid-area: 3 / 1; }
.empty-qr span:nth-child(5) { grid-area: 3 / 3 / 5 / 5; background: transparent; border: 4px solid #90a199; }
.empty-qr span:nth-child(6) { grid-area: 4 / 1; }
.empty-qr span:nth-child(7) { grid-area: 3 / 2; }
.items-list { display: grid; gap: 13px; }
.qr-card { padding: 17px 18px 11px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: 0 3px 15px rgba(28, 48, 39, 0.035); }
.qr-card.has-error { border-color: #e6bcb7; }
.qr-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.qr-card-title { color: var(--muted); font-size: 10px; line-height: 1; font-weight: 800; letter-spacing: 0.7px; text-transform: uppercase; }
.qr-status { color: var(--muted); font-size: 10px; }
.qr-status.error { color: var(--danger); }
.qr-card-body { display: grid; grid-template-columns: 83px minmax(0, 1fr); gap: 15px; }
.item-qr-preview { width: 83px; height: 83px; border: 1px solid var(--line); border-radius: 8px; display: grid; place-items: center; overflow: hidden; background: #fff; }
.item-qr-image { display: block; width: 77px; height: 77px; object-fit: contain; }
.item-qr-preview:has(.item-qr-image:not([src])) .item-qr-placeholder,
.item-qr-image:not([src]) + .item-qr-placeholder { display: grid; }
.item-qr-image[src] + .item-qr-placeholder { display: none; }
.item-qr-placeholder { display: none; color: #a5afa9; font-family: var(--mono); font-size: 16px; }
.item-fields { display: grid; gap: 10px; min-width: 0; }
.item-fields label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 600; }
.item-text {
  width: 100%; min-height: 48px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft);
  font-family: var(--mono); font-size: 10px; line-height: 1.45; font-weight: 400;
}
.item-secondary-fields { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 10px; }
.item-secondary-fields input { width: 100%; height: 32px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); font-size: 11px; font-weight: 400; }
.item-secondary-fields .item-size { padding-right: 33px !important; }
.item-error { margin: 11px 0 0; padding: 7px 9px; border-radius: 6px; background: var(--danger-soft); color: var(--danger); font-size: 10px; line-height: 1.5; }
.qr-card-actions { display: flex; align-items: center; gap: 6px; margin-top: 11px; padding-top: 9px; border-top: 1px solid #edf0ed; }
.card-action-spacer { flex: 1; }
.qr-card-actions .icon-button { width: 27px; height: 27px; border-color: transparent; background: transparent; }
.delete-button:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); }

.preview-column { position: sticky; top: 20px; min-width: 0; }
.preview-panel { padding: 23px 25px 21px; overflow: hidden; }
.preview-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.preview-heading .eyebrow { margin-bottom: 3px; font-size: 9px; }
.preview-heading h2 { font-size: 20px; }
.page-badge { padding: 5px 9px; border-radius: 6px; background: var(--surface-soft); border: 1px solid var(--line); color: var(--muted); font-size: 10px; white-space: nowrap; }
.page-navigation { margin: 15px 0 12px; display: flex; align-items: center; justify-content: center; gap: 13px; }
.page-navigation .icon-button { width: 28px; height: 28px; }
#page-indicator { min-width: 94px; text-align: center; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.paper-container {
  padding: 18px;
  border: 1px solid #d5ddd6;
  border-radius: 10px;
  background-color: #e9ede8;
  background-image: radial-gradient(#cdd6ce 0.6px, transparent 0.6px);
  background-size: 7px 7px;
}
.paper {
  position: relative;
  width: min(100%, 390px);
  aspect-ratio: 210 / 297;
  margin: 0 auto;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 3px 13px rgba(28, 39, 33, 0.17), 0 0 0 1px rgba(70, 84, 74, 0.05);
}
.paper-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: #a0aaa4; text-align: center; font-size: 10px; line-height: 1.6; }
.paper-empty-icon { display: grid; place-items: center; width: 42px; height: 54px; border: 1px solid #d9dedb; border-radius: 3px; color: #a2aca6; font-size: 11px; font-weight: 700; }
#placements { position: absolute; inset: 0; }
.placement { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; }
.placement img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; }
.placement-label { width: 100%; margin-top: 1.3%; overflow: hidden; color: #28332e; text-align: center; white-space: nowrap; text-overflow: ellipsis; font-size: clamp(3px, 0.75vw, 6px); line-height: 1.2; }
.layout-error { display: flex; gap: 7px; margin: 11px 0 0; padding: 9px 11px; border-radius: 7px; color: var(--danger); background: var(--danger-soft); font-size: 11px; line-height: 1.5; }
.print-settings { margin: 19px 0 0; padding: 15px 0 0; border: 0; border-top: 1px solid var(--line); }
.print-settings legend { padding: 0 10px 0 0; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.65px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 12px; }
.setting-field { display: grid; gap: 6px; color: var(--muted); font-size: 10px; }
.setting-field input { width: 100%; height: 34px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; font-size: 11px; }
.toggle-field { display: flex; align-items: center; gap: 7px; min-height: 34px; color: var(--muted); font-size: 11px; cursor: pointer; }
.toggle-field input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { position: relative; width: 31px; height: 18px; border-radius: 20px; background: #cbd2cd; transition: background 0.15s; }
.toggle-track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: transform 0.15s; }
.toggle-field input:checked + .toggle-track { background: var(--accent); }
.toggle-field input:checked + .toggle-track::after { transform: translateX(13px); }
.toggle-field input:focus-visible + .toggle-track { outline: 3px solid rgba(23, 107, 93, 0.22); outline-offset: 2px; }
.export-area { margin-top: 19px; }
.export-summary { margin-bottom: 9px; color: var(--muted); text-align: center; font-size: 10px; min-height: 15px; }
.download-button { min-height: 46px; font-size: 13px; }
.print-note { display: flex; align-items: flex-start; justify-content: center; gap: 6px; margin: 11px 0 0; color: var(--muted); font-size: 9px; line-height: 1.55; text-align: center; }
.print-note svg { width: 13px; height: 13px; margin-top: 1px; }
.print-note strong { font-weight: 650; color: #5d6a63; }

.app-footer { max-width: 1380px; margin: 0 auto; padding: 20px 28px 28px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 20px; color: #829087; font-size: 10px; }
.app-footer span:first-child { color: #5f7067; font-weight: 700; }
.toast {
  position: fixed; z-index: 20; left: 50%; bottom: 25px; transform: translate(-50%, 15px); max-width: calc(100vw - 32px); padding: 11px 17px;
  border-radius: 9px; color: #fff; background: #253b32; box-shadow: 0 8px 35px rgba(0, 0, 0, 0.2);
  font-size: 12px; line-height: 1.5; text-align: center; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #873c37; }

@media (min-width: 1250px) {
  .workspace { grid-template-columns: minmax(0, 1.07fr) minmax(450px, 0.93fr); gap: 34px; }
  .paper { width: min(100%, 415px); }
}

@media (max-width: 1020px) {
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(370px, 0.9fr); gap: 20px; }
  .app-shell { padding-inline: 20px; }
  .preview-panel { padding-inline: 19px; }
  .paper-container { padding: 13px; }
  .local-save-note { display: none; }
}

@media (max-width: 820px) {
  .app-header { padding-inline: 20px; }
  .workspace { grid-template-columns: 1fr; }
  .preview-column { position: static; }
  .preview-panel { max-width: 590px; width: 100%; margin: 8px auto 0; }
  .paper { width: min(100%, 430px); }
  .placement-label { font-size: clamp(3px, 1vw, 6px); }
  .app-shell { padding-top: 32px; }
}

@media (max-width: 560px) {
  .app-header { height: 64px; padding-inline: 16px; }
  .brand { gap: 8px; }
  .brand-mark { width: 31px; height: 31px; }
  .brand-name { font-size: 18px; }
  .brand-tag { display: none; }
  .privacy-note { display: none; }
  .header-actions { gap: 8px; }
  .header-actions .button { min-height: 34px; padding: 7px 10px; font-size: 10px; }
  .lang-switch { padding: 2px; }
  .lang-button { min-width: 28px; height: 24px; padding: 0 5px; font-size: 9px; }
  .app-shell { padding: 25px 14px 38px; }
  .intro { margin-bottom: 23px; }
  h1 { font-size: 31px; letter-spacing: -1.2px; }
  .intro-copy { font-size: 13px; }
  .input-panel { padding: 19px 16px; }
  .input-options { gap: 10px; }
  .checkbox-label { font-size: 11px; }
  .compact-field { gap: 6px; }
  .compact-field > span:first-child { display: none; }
  .qr-card { padding-inline: 13px; }
  .qr-card-body { grid-template-columns: 66px minmax(0, 1fr); gap: 11px; }
  .item-qr-preview { width: 66px; height: 66px; }
  .item-qr-image { width: 61px; height: 61px; }
  .item-secondary-fields { grid-template-columns: 89px minmax(0, 1fr); gap: 7px; }
  .preview-panel { padding: 20px 14px; }
  .paper-container { padding: 14px 9px; }
  .settings-grid { gap: 9px; }
  .toggle-field { gap: 5px; }
  .app-footer { padding-inline: 17px; flex-direction: column; gap: 6px; text-align: center; }
  .placement-label { font-size: clamp(3px, 1.2vw, 5px); }
}

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

@media print {
  body { background: #fff; }
  .app-header, .intro, .editor-column, .preview-heading, .page-navigation, .print-settings, .export-area, .app-footer, .toast { display: none !important; }
  .app-shell, .workspace, .preview-column, .preview-panel, .paper-container { display: block; padding: 0; margin: 0; max-width: none; border: 0; box-shadow: none; background: #fff; }
  .paper { width: 210mm; height: 297mm; box-shadow: none; }
}
