:root {
  --ink: #1d1917;
  --muted: #736b66;
  --paper: #f7f4ee;
  --surface: #fffdf9;
  --line: #ded8ce;
  --accent: #a42026;
  --accent-dark: #7f171b;
  --accent-soft: #f3e2df;
  --green: #216b49;
  --green-soft: #deeee5;
  --shadow: 0 18px 50px rgba(42, 31, 24, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(164, 32, 38, 0.22);
  outline-offset: 2px;
}

.wrap {
  width: min(1240px, calc(100% - 48px));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(77, 62, 53, 0.12);
  background: rgba(247, 244, 238, 0.9);
  backdrop-filter: blur(16px);
}

.header-inner {
  width: min(1360px, calc(100% - 48px));
  height: 78px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand,
.brand img {
  display: block;
}

.brand img {
  width: 122px;
  height: 42px;
  object-fit: contain;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c58c36;
  box-shadow: 0 0 0 4px rgba(197, 140, 54, 0.12);
}

.sync-status.is-live .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(33, 107, 73, 0.12);
}

.sync-status.is-loading .status-dot {
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

.button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 750;
  transition: 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-ghost,
.button-secondary {
  border-color: #bdb5aa;
  background: transparent;
  color: var(--ink);
}

.button-ghost:hover,
.button-secondary:hover {
  border-color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
}

.button-primary {
  background: var(--accent);
  color: white;
}

.button-primary:hover {
  background: var(--accent-dark);
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

h2,
h3,
p {
  text-wrap: pretty;
}

h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.045em;
}

.catalogue {
  padding-block: 64px 110px;
}

.catalogue-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 34px;
}

.catalogue-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.catalogue-heading .eyebrow {
  margin-bottom: 10px;
}

h2 {
  margin: 0;
  font-size: clamp(2.5rem, 5vw, 4.8rem);
  line-height: 1;
}

.refresh-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.refresh-button:hover {
  color: var(--accent);
}

.refresh-button.is-spinning span {
  animation: spin 0.7s linear infinite;
}

.pdf-button {
  min-height: 42px;
  padding: 0 17px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-size: 0.78rem;
  font-weight: 750;
  transition: 160ms ease;
}

.pdf-button:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: var(--accent);
}

.pdf-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 30px;
}

.search-box {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
}

.search-box span {
  font-size: 1.25rem;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.search-box input::placeholder {
  color: #99918a;
}

.filters {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 249, 0.64);
}

.filter {
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  white-space: nowrap;
}

.filter:hover,
.filter.is-active {
  background: var(--ink);
  color: white;
}

.sort-control select {
  min-height: 48px;
  padding: 0 38px 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
}

.notice {
  margin: 0 0 24px;
  padding: 13px 16px;
  border: 1px solid #e1c29b;
  border-radius: 10px;
  background: #fff4e6;
  color: #7a4d19;
  font-size: 0.86rem;
  line-height: 1.5;
}

.print-header {
  display: none;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.product-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(30, 22, 17, 0.02);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.image-wrap {
  position: relative;
  aspect-ratio: 4 / 4.6;
  overflow: hidden;
  background: #e9e3da;
}

.product-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 450ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.product-card:hover .product-image {
  transform: scale(1.025);
}

.image-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-content: center;
  gap: 8px;
  background: linear-gradient(145deg, #eee8de, #ddd4c7);
  color: var(--accent);
  text-align: center;
}

.image-fallback span {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.6rem;
  letter-spacing: 0.08em;
}

.image-fallback small {
  color: var(--muted);
  font-size: 0.7rem;
}

.stock-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.9);
  color: var(--green);
  box-shadow: 0 4px 14px rgba(31, 23, 18, 0.1);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.stock-badge.is-low {
  color: #9b5a16;
}

.stock-badge.is-out {
  color: var(--accent);
}

.product-body {
  padding: 22px;
}

.product-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.article-label {
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.article-number {
  margin: 5px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 500;
  letter-spacing: -0.025em;
}

.prices {
  display: grid;
  justify-items: end;
  gap: 2px;
  text-align: right;
}

.mrp {
  color: #9d958e;
  font-size: 0.72rem;
  text-decoration: line-through;
}

.wsp {
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 600;
}

.prices small {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.09em;
}

.rule {
  height: 1px;
  margin: 20px 0 17px;
  background: var(--line);
}

.sizes-heading,
.product-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sizes-heading {
  margin-bottom: 11px;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.size-type {
  color: var(--accent);
}

.size-list {
  min-height: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.size-chip {
  min-width: 40px;
  padding: 7px 8px;
  display: grid;
  justify-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
}

.size-chip strong {
  font-size: 0.75rem;
}

.size-chip small {
  color: var(--muted);
  font-size: 0.63rem;
}

.size-chip.is-empty {
  opacity: 0.42;
  background: #f5f2ed;
}

.product-total {
  margin-top: 17px;
  padding-top: 15px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}

.product-total strong {
  color: var(--ink);
  font-size: 0.88rem;
}

.empty-state {
  padding: 80px 20px;
  text-align: center;
}

.empty-mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 1.4rem;
}

.empty-state h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
  font-weight: 500;
}

.empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
}

.site-footer {
  border-top: 1px solid #332d29;
  background: #211d1a;
  color: #f5efe5;
}

.footer-inner {
  min-height: 124px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}

.footer-inner img {
  width: 90px;
  height: 38px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.footer-inner p {
  margin: 0;
  color: #bdb4ab;
  font-size: 0.75rem;
}

.footer-inner p:nth-of-type(1) {
  color: #f5efe5;
  text-align: center;
}

.footer-inner p:last-child {
  text-align: right;
}

.sheet-dialog {
  width: min(590px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(22, 16, 12, 0.25);
}

.sheet-dialog::backdrop {
  background: rgba(31, 24, 20, 0.58);
  backdrop-filter: blur(4px);
}

.dialog-card {
  position: relative;
  padding: 38px;
}

.dialog-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
}

.dialog-card .eyebrow {
  margin-bottom: 10px;
}

.dialog-card h2 {
  max-width: 420px;
  font-size: clamp(2rem, 6vw, 3.25rem);
}

.dialog-intro {
  margin: 18px 0 28px;
  color: var(--muted);
  line-height: 1.6;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.url-input {
  width: 100%;
  height: 52px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
  color: var(--ink);
}

.dialog-help {
  margin-top: 14px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.5;
}

.dialog-help span {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.dialog-help code {
  white-space: normal;
}

.dialog-actions {
  margin-top: 28px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-error {
  min-height: 1.2em;
  margin: 12px 0 0;
  color: var(--accent);
  font-size: 0.76rem;
  text-align: right;
}

.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;
}

@keyframes pulse {
  50% { opacity: 0.35; transform: scale(0.8); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 980px) {
  .toolbar {
    grid-template-columns: 1fr auto;
  }

  .filters {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    overflow-x: auto;
  }

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

@media (max-width: 640px) {
  .wrap,
  .header-inner {
    width: min(100% - 28px, 1240px);
  }

  .header-inner {
    height: 68px;
  }

  .brand img {
    width: 94px;
  }

  .sync-status {
    display: none;
  }

  .button-ghost {
    min-height: 38px;
    padding-inline: 14px;
  }

  .catalogue {
    padding-block: 52px 76px;
  }

  .catalogue-heading {
    align-items: flex-end;
  }

  .catalogue-actions {
    gap: 10px;
  }

  .pdf-button {
    min-height: 38px;
    padding-inline: 13px;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .sort-control,
  .sort-control select {
    width: 100%;
  }

  .filters {
    grid-column: auto;
    grid-row: auto;
  }

  .filter {
    flex: 1 0 auto;
  }

  .product-grid {
    grid-template-columns: 1fr;
  }

  .dialog-card {
    padding: 32px 22px 24px;
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions .button {
    width: 100%;
  }

  .footer-inner {
    padding-block: 28px;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 8px;
  }

  .footer-inner p:last-child {
    text-align: center;
  }
}

@page {
  size: A4 portrait;
  margin: 11mm;
}

@media print {
  :root {
    --paper: #ffffff;
    --surface: #ffffff;
    --line: #d8d2ca;
  }

  html,
  body {
    width: 100%;
    background: white !important;
    color: #1d1917 !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .site-header,
  .catalogue-heading,
  .toolbar,
  .notice,
  .empty-state,
  .site-footer,
  .sheet-dialog {
    display: none !important;
  }

  .catalogue,
  .wrap {
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .print-header {
    margin-bottom: 7mm;
    padding-bottom: 5mm;
    display: block;
    border-bottom: 1.5px solid var(--accent);
  }

  .print-brand-row,
  .print-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10mm;
  }

  .print-brand-row img {
    width: 31mm;
    height: 13mm;
    object-fit: contain;
  }

  .print-brand-row > div {
    display: grid;
    justify-items: end;
    gap: 1.2mm;
  }

  .print-brand-row strong {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 15pt;
    font-weight: 500;
  }

  .print-brand-row span,
  .print-summary {
    color: #736b66;
    font-size: 7.5pt;
  }

  .print-summary {
    margin-top: 4mm;
    padding-top: 3mm;
    border-top: 1px solid #e7e2db;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .product-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4mm;
  }

  .product-card {
    break-inside: avoid;
    page-break-inside: avoid;
    border-radius: 3mm;
    box-shadow: none;
  }

  .product-card:hover {
    transform: none;
    box-shadow: none;
  }

  .image-wrap {
    height: 58mm;
    aspect-ratio: auto;
  }

  .product-image {
    object-fit: cover;
  }

  .stock-badge {
    top: 2.5mm;
    right: 2.5mm;
    padding: 1.5mm 2mm;
    box-shadow: none;
    font-size: 5.5pt;
  }

  .product-body {
    padding: 3.2mm;
  }

  .product-topline {
    gap: 2mm;
  }

  .article-label,
  .sizes-heading {
    font-size: 5.5pt;
  }

  .article-number {
    margin-top: 1mm;
    font-size: 10pt;
  }

  .mrp {
    font-size: 5.5pt;
  }

  .wsp {
    font-size: 9.5pt;
  }

  .prices small {
    font-size: 4.5pt;
  }

  .rule {
    margin: 3mm 0 2.5mm;
  }

  .sizes-heading {
    margin-bottom: 2mm;
  }

  .size-list {
    min-height: 0;
    gap: 1mm;
  }

  .size-chip {
    min-width: 8mm;
    padding: 1.2mm 1mm;
    gap: 0.4mm;
    border-radius: 1.5mm;
  }

  .size-chip strong {
    font-size: 6pt;
  }

  .size-chip small {
    font-size: 5pt;
  }

  .product-total {
    margin-top: 2.5mm;
    padding-top: 2.5mm;
    font-size: 5.5pt;
  }

  .product-total strong {
    font-size: 6.5pt;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
