:root {
  --wine: #7b1125;
  --wine-deep: #4a0714;
  --gold: #a79457;
  --ink: #3b3b38;
  --muted-ink: #67615d;
  --paper: #efeae7;
  --soft-white: #fbfaf8;
  --hairline: #cfc7c1;
  --field: #fffdfb;
  --display: "Cormorant Garamond", Georgia, serif;
  --sans: "Raleway", Arial, sans-serif;
  --shadow: rgba(28, 19, 18, 0.24);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body,
.print-sheet,
.print-sheet * {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

html {
  min-height: 100%;
  background: #2f2c2b;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 16%, rgba(123, 17, 37, 0.3), transparent 25rem),
    linear-gradient(135deg, #2f2c2b 0%, #171514 100%);
  font-family: var(--sans);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(100%, 1280px);
  margin: 0 auto;
  padding: 28px 22px 46px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 22px;
  background: var(--paper);
  border: 1px solid rgba(167, 148, 87, 0.38);
  border-radius: var(--radius);
  box-shadow: 0 8px 18px rgba(23, 21, 20, 0.18);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-lockup img {
  width: 88px;
  flex: 0 0 auto;
}

.brand-kicker {
  margin: 0 0 2px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  color: var(--wine);
  font-family: var(--display);
  font-size: 2.45rem;
  font-weight: 700;
  line-height: 0.94;
  letter-spacing: 0;
  text-transform: uppercase;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-size: 0.83rem;
  font-weight: 800;
  border: 1px solid transparent;
}

.button-primary {
  color: var(--soft-white);
  background: var(--wine);
  border-color: var(--wine);
}

.button-primary:hover,
.button-primary:focus-visible {
  background: var(--wine-deep);
}

.button-muted {
  color: var(--wine);
  background: rgba(251, 250, 248, 0.82);
  border-color: rgba(167, 148, 87, 0.48);
}

.button-muted:hover,
.button-muted:focus-visible {
  background: var(--soft-white);
  border-color: var(--gold);
}

.controls {
  display: grid;
  grid-template-columns: repeat(7, minmax(132px, 1fr));
  align-items: end;
  gap: 14px;
  margin-top: 14px;
  padding: 16px 18px;
  background: var(--soft-white);
  border: 1px solid rgba(207, 199, 193, 0.88);
  border-radius: var(--radius);
}

.field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.field span,
.edit-toggle span {
  color: var(--muted-ink);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

select,
input[type="search"],
.price-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(103, 97, 93, 0.36);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--field);
  outline: none;
}

select,
input[type="search"] {
  padding: 0 12px;
}

select:focus-visible,
input:focus-visible,
.segmented button:focus-visible,
.button:focus-visible {
  outline: 2px solid rgba(123, 17, 37, 0.38);
  outline-offset: 2px;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  min-height: 38px;
  padding: 3px;
  background: #eee7e1;
  border: 1px solid rgba(207, 199, 193, 0.9);
  border-radius: var(--radius);
}

.segmented button {
  min-width: 0;
  border: 0;
  border-radius: 6px;
  color: var(--muted-ink);
  background: transparent;
  font-size: 0.79rem;
  font-weight: 800;
}

.segmented button[aria-pressed="true"] {
  color: var(--wine);
  background: var(--soft-white);
}

.edit-toggle {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid rgba(167, 148, 87, 0.42);
  border-radius: var(--radius);
  background: var(--field);
}

.edit-toggle span {
  line-height: 1.05;
}

.edit-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--wine);
}

.data-status {
  min-height: 20px;
  margin: 16px 4px 14px;
  color: rgba(251, 250, 248, 0.86);
  font-size: 0.88rem;
  font-weight: 600;
}

.data-status.is-error {
  width: fit-content;
  max-width: 100%;
  padding: 12px 14px;
  color: var(--wine-deep);
  background: var(--paper);
  border: 1px solid rgba(167, 148, 87, 0.54);
  border-radius: var(--radius);
}

.workspace {
  min-width: 0;
}

.list-view {
  display: grid;
  gap: 22px;
}

.category-section {
  display: grid;
  gap: 10px;
}

.category-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 0 2px 8px;
  border-bottom: 1px solid rgba(167, 148, 87, 0.42);
}

.category-heading h2 {
  color: var(--paper);
  font-family: var(--display);
  font-size: 1.72rem;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

.category-heading span {
  color: rgba(251, 250, 248, 0.72);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.wine-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1.5fr) minmax(180px, 0.7fr) minmax(132px, 0.42fr);
  gap: 16px;
  align-items: center;
  min-height: 120px;
  padding: 12px 16px;
  background: var(--paper);
  border: 1px solid rgba(207, 199, 193, 0.86);
  border-radius: var(--radius);
}

.wine-image {
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(251, 250, 248, 0.64);
  border: 1px solid rgba(207, 199, 193, 0.7);
  border-radius: var(--radius);
  overflow: hidden;
}

.wine-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 5px;
}

.wine-main {
  min-width: 0;
}

.wine-name {
  color: var(--wine);
  font-family: var(--display);
  font-size: 1.36rem;
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: 0;
  text-transform: uppercase;
  text-wrap: balance;
}

.wine-house {
  margin-top: 4px;
  color: var(--ink);
  font-size: 0.83rem;
  font-weight: 800;
}

.wine-meta,
.wine-tags {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.wine-meta span,
.wine-tags span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  color: var(--ink);
  background: rgba(251, 250, 248, 0.78);
  border: 1px solid rgba(207, 199, 193, 0.82);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.wine-detail {
  min-width: 0;
  display: grid;
  gap: 7px;
  color: var(--muted-ink);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
}

.wine-detail strong {
  color: var(--ink);
  font-weight: 800;
}

.price-cell {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.price-value {
  color: var(--wine);
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.price-input {
  max-width: 126px;
  padding: 0 10px;
  color: var(--wine);
  font-weight: 800;
  text-align: right;
}

.whatsapp-link {
  color: var(--wine);
  font-size: 0.72rem;
  font-weight: 800;
  text-decoration-color: rgba(123, 17, 37, 0.42);
}

.empty-state {
  padding: 28px;
  color: var(--paper);
  border: 1px solid rgba(167, 148, 87, 0.42);
  border-radius: var(--radius);
}

.print-preview {
  overflow-x: auto;
}

.print-book {
  display: grid;
  gap: 28px;
  justify-content: center;
  padding-bottom: 24px;
}

.print-sheet {
  width: 8.5in;
  height: 11in;
  display: grid;
  grid-template-rows: 0.72in minmax(0, 1fr) 0.48in;
  gap: 0.12in;
  padding: 0.34in 0.38in 0.26in;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 24px 70px var(--shadow);
}

.print-header,
.print-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.18in;
}

.print-header {
  border-bottom: 1px solid rgba(167, 148, 87, 0.5);
  padding-bottom: 0.1in;
}

.print-title {
  min-width: 0;
}

.print-title p {
  color: var(--gold);
  font-size: 7.2pt;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.print-title h2 {
  color: var(--wine);
  font-family: var(--display);
  font-size: 25pt;
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: 0;
  text-transform: uppercase;
}

.print-title h2.is-long {
  font-size: 21pt;
}

.print-title h2.is-very-long {
  font-size: 17pt;
}

.print-header img {
  width: 1.15in;
  flex: 0 0 auto;
}

.print-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 0.12in;
}

.print-card {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 0.16in;
  background: rgba(251, 250, 248, 0.8);
  border: 1px solid rgba(207, 199, 193, 0.9);
  border-radius: 0.08in;
}

.print-card:nth-child(4n + 1),
.print-card:nth-child(4n + 4) {
  background: rgba(251, 250, 248, 0.96);
}

.print-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.08in;
  padding-bottom: 0.08in;
  border-bottom: 1px solid rgba(167, 148, 87, 0.46);
}

.print-category {
  color: var(--muted-ink);
  font-size: 6.6pt;
  font-weight: 800;
  letter-spacing: 0.11em;
  line-height: 1.1;
  text-transform: uppercase;
}

.print-price {
  flex: 0 0 auto;
  color: var(--wine);
  font-family: var(--display);
  font-size: 21pt;
  font-weight: 700;
  line-height: 1;
}

.print-card-body {
  min-height: 0;
  display: grid;
  grid-template-columns: 1.18in minmax(0, 1fr);
  gap: 0.12in;
  align-items: center;
  padding: 0.11in 0 0.08in;
}

.print-bottle {
  height: 2.55in;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(239, 234, 231, 0.74);
  border-radius: 0.06in;
  overflow: hidden;
}

.print-bottle img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.05in;
}

.print-copy {
  min-width: 0;
}

.print-wine-name {
  color: var(--wine);
  font-family: var(--display);
  font-size: 16pt;
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: 0;
  text-transform: uppercase;
  text-wrap: balance;
}

.print-wine-name.is-long {
  font-size: 13.5pt;
}

.print-wine-name.is-very-long {
  font-size: 11.2pt;
}

.print-house {
  margin-top: 0.06in;
  color: var(--ink);
  font-size: 7.6pt;
  font-weight: 800;
  line-height: 1.18;
}

.print-detail {
  margin-top: 0.07in;
  color: var(--muted-ink);
  font-size: 7.2pt;
  font-weight: 600;
  line-height: 1.25;
}

.print-detail strong {
  color: var(--ink);
  font-weight: 800;
}

.print-card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.05in;
  padding-top: 0.08in;
  border-top: 1px solid rgba(207, 199, 193, 0.88);
}

.print-chip {
  padding: 0.025in 0.055in;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid rgba(207, 199, 193, 0.88);
  border-radius: 999px;
  font-size: 6.2pt;
  font-weight: 700;
}

.print-footer {
  border-top: 1px solid rgba(167, 148, 87, 0.5);
  padding-top: 0.08in;
  color: var(--muted-ink);
  font-size: 6.7pt;
  font-weight: 700;
  line-height: 1.25;
}

.print-footer strong {
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.print-page-number {
  flex: 0 0 auto;
  color: var(--wine);
  font-weight: 800;
}

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

@media (max-width: 1120px) {
  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 18px 14px 34px;
  }

  .topbar,
  .brand-lockup,
  .controls {
    display: grid;
  }

  .brand-lockup {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .brand-lockup img {
    width: 76px;
  }

  h1 {
    font-size: 2rem;
  }

  .action-row {
    justify-content: stretch;
  }

  .action-row .button {
    flex: 1 1 84px;
  }

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

  .wine-row {
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: start;
  }

  .wine-image {
    height: 82px;
  }

  .wine-detail,
  .price-cell {
    grid-column: 2;
  }

  .price-cell {
    justify-items: start;
  }
}

@media print {
  html,
  body {
    width: 8.5in;
    min-height: 11in;
    background: var(--paper);
  }

  body {
    margin: 0;
  }

  .app-shell {
    width: 8.5in;
    max-width: none;
    padding: 0;
    margin: 0;
  }

  .topbar,
  .controls,
  .data-status,
  .list-view {
    display: none !important;
  }

  .workspace,
  .print-preview,
  .print-book {
    display: block !important;
    width: 8.5in;
    padding: 0;
    margin: 0;
    overflow: visible;
  }

  .print-sheet {
    width: 8.5in;
    height: 11in;
    padding: 0.34in 0.38in 0.26in;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }

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