:root {
  --bg-page: #0c0e14;
  --surface: #141821;
  --text-primary: #f4f6fa;
  --text-secondary: #8e95a2;
  --text-nav: #d8dee9;
  --text-quiet-btn: #e5e8ee;
  --nav-bg: rgba(255, 255, 255, 0.06);
  --nav-bg-hover: rgba(255, 255, 255, 0.10);
  --quiet-bg: rgba(255, 255, 255, 0.07);
  --quiet-bg-hover: rgba(255, 255, 255, 0.11);
  --stepper-bg: rgba(255, 255, 255, 0.08);
  --stepper-bg-hover: rgba(255, 255, 255, 0.14);
  --check-off-bg: rgba(255, 255, 255, 0.09);
  --row-hover-bg: rgba(255, 255, 255, 0.03);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.page-shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 16px 0;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.top-bar-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.lang-switch {
  background: var(--nav-bg);
  border-radius: 10px;
  padding: 3px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: none;
}

.lang-btn {
  appearance: none;
  border: none;
  border-radius: 7px;
  padding: 5px 9px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: background-color 140ms ease, color 140ms ease;
}

.lang-btn:hover:not(.is-active) {
  color: var(--text-nav);
}

.lang-btn.is-active {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-primary);
}

.lang-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(244, 246, 250, 0.32);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 13px;
  border: none;
  border-radius: 10px;
  background: var(--nav-bg);
  color: var(--text-nav);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.2;
  transition: background-color 150ms ease, transform 120ms ease;
}

.nav-btn:hover {
  background: var(--nav-bg-hover);
}

.nav-btn:active {
  transform: scale(0.985);
}

.nav-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(244, 246, 250, 0.32);
}

.icon-nav {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.selector-card {
  background: var(--surface);
  border: none;
  border-radius: 16px;
  padding: 22px;
}

.selector-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.selector-titles {
  min-width: 0;
}

.selector-titles h1 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.selector-sub {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.48;
  font-weight: 400;
  color: var(--text-secondary);
}

.quiet-chip-btn {
  appearance: none;
  flex-shrink: 0;
  height: 34px;
  padding: 0 12px;
  border: none;
  border-radius: 9px;
  background: var(--quiet-bg);
  color: var(--text-quiet-btn);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color 150ms ease, transform 120ms ease;
}

.quiet-chip-btn:hover {
  background: var(--quiet-bg-hover);
}

.quiet-chip-btn:active {
  transform: scale(0.98);
}

.quiet-chip-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(244, 246, 250, 0.32);
}

.template-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.template-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  margin: 0 -10px;
  border: none;
  border-radius: 12px;
  background: transparent;
  transition: background-color 140ms ease;
}

.template-row:hover {
  background: var(--row-hover-bg);
}

.row-toggle {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  user-select: none;
}

.row-toggle:focus-visible {
  outline: none;
}

.row-toggle:focus-visible .row-check {
  box-shadow: 0 0 0 2px rgba(244, 246, 250, 0.45);
}

.row-check {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border: none;
  border-radius: 6px;
  background: var(--check-off-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 140ms ease, transform 120ms ease;
}

.row-check svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: #0c0e14;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 120ms ease, transform 120ms ease;
}

.template-row.is-checked .row-check {
  background: #f4f6fa;
}

.template-row.is-checked .row-check svg {
  opacity: 1;
  transform: scale(1);
}

.row-thumb {
  width: 34px;
  height: 48px;
  flex-shrink: 0;
  border: none;
  border-radius: 4px;
  background: #ffffff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 150ms ease;
}

.row-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  transition: opacity 150ms ease;
}

.row-title {
  font-size: 15px;
  line-height: 1.25;
  font-weight: 500;
  color: #f4f6fa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  font-size: 12.5px;
  line-height: 1.25;
  font-weight: 400;
  color: #8e95a2;
}

.template-row.is-off .row-thumb,
.template-row.is-off .row-info {
  opacity: 0.48;
}

.qty-stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.qty-btn {
  appearance: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: var(--stepper-bg);
  color: #f4f6fa;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: background-color 140ms ease, transform 110ms ease, opacity 140ms ease;
}

.qty-btn:hover:not(:disabled) {
  background: var(--stepper-bg-hover);
}

.qty-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.qty-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(244, 246, 250, 0.35);
}

.qty-btn:disabled {
  opacity: 0.32;
  cursor: default;
}

.qty-val {
  min-width: 24px;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
  color: #f4f6fa;
  transition: opacity 140ms ease;
}

.template-row.is-off .qty-val {
  opacity: 0.42;
}

.action-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 18px;
}

.print-primary-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  padding: 0 20px;
  border: none;
  border-radius: 12px;
  background: #f4f6fa;
  color: #0c0e14;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  user-select: none;
  transition: background-color 150ms ease, transform 120ms ease, opacity 150ms ease;
}

.print-primary-btn:hover:not(:disabled) {
  background: #ffffff;
}

.print-primary-btn:active:not(:disabled) {
  transform: scale(0.985);
}

.print-primary-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-page), 0 0 0 4px rgba(244, 246, 250, 0.55);
}

.print-primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pdf-secondary-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  padding: 0 18px;
  border: none;
  border-radius: 12px;
  background: var(--quiet-bg);
  color: var(--text-quiet-btn);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color 150ms ease, transform 120ms ease;
}

.pdf-secondary-btn:hover {
  background: var(--quiet-bg-hover);
}

.pdf-secondary-btn:active {
  transform: scale(0.985);
}

.pdf-secondary-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(244, 246, 250, 0.32);
}

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 0 12px;
  padding: 0 2px;
}

.preview-caption {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.print-mount {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 48px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.print-mount.single-sheet {
  grid-template-columns: minmax(0, 420px);
  justify-content: center;
}

.print-sheet-page {
  width: 100%;
  aspect-ratio: 210 / 297;
  background: #ffffff;
  border: none;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.38);
}

.print-sheet-page svg {
  display: block;
  width: 100%;
  height: 100%;
}

@media (max-width: 560px) {
  .top-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .top-bar-right {
    gap: 6px;
  }

  .nav-btn {
    padding: 7px 10px;
    font-size: 12.5px;
  }

  .lang-btn {
    padding: 4px 8px;
    font-size: 12px;
  }

  .selector-card {
    padding: 18px 14px;
  }

  .selector-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .template-row {
    gap: 8px;
    padding: 8px 8px;
    margin: 0 -8px;
  }

  .row-toggle {
    gap: 9px;
  }

  .row-thumb {
    width: 30px;
    height: 42px;
  }

  .row-title {
    font-size: 14px;
    white-space: normal;
  }

  .row-sub {
    font-size: 12px;
  }

  .qty-stepper {
    gap: 4px;
  }

  .qty-btn {
    width: 28px;
    height: 28px;
  }

  .qty-val {
    min-width: 20px;
    font-size: 13.5px;
  }

  .action-bar {
    grid-template-columns: 1fr;
  }

  .pdf-secondary-btn {
    height: 44px;
  }

  .print-mount {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .print-mount.single-sheet {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    width: 210mm !important;
    height: auto !important;
    min-height: 0 !important;
    background: #ffffff !important;
    background-image: none !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .screen-only {
    display: none !important;
  }

  .print-mount,
  .print-mount.single-sheet {
    display: block !important;
    max-width: none !important;
    width: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .print-sheet-page {
    display: block !important;
    width: 210mm !important;
    height: 296.8mm !important;
    aspect-ratio: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: #ffffff !important;
    box-shadow: none !important;
    overflow: hidden !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    break-after: page !important;
    page-break-after: always !important;
  }

  .print-sheet-page:last-child {
    break-after: auto !important;
    page-break-after: auto !important;
  }

  .print-sheet-page svg {
    display: block !important;
    width: 210mm !important;
    height: 296.8mm !important;
  }
}
