:root {
  color-scheme: light;
  --ink: #24181a;
  --muted: #6e6061;
  --line: #e7ddda;
  --paper: #fffdf9;
  --wash: #f6efe8;
  --wine: #6d1734;
  --wine-dark: #471123;
  --leaf: #657a46;
  --gold: #bd8c42;
  --danger: #9e2f2f;
  --shadow: 0 16px 44px rgba(47, 21, 28, 0.12);
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #fbf7f1 0%, #f4ebe2 100%);
  color: var(--ink);
}

.hidden {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-header {
  align-items: center;
  background: var(--wine);
  color: #fffaf4;
  display: flex;
  justify-content: space-between;
  min-height: 116px;
  overflow: hidden;
  padding: 24px clamp(16px, 5vw, 40px);
  position: relative;
}

.site-nav {
  align-items: center;
  background: rgba(255, 250, 244, 0.94);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 14px clamp(16px, 5vw, 40px);
  position: sticky;
  top: 0;
  z-index: 4;
}

.public-main {
  max-width: none;
  padding: 0;
}

.hero {
  align-items: end;
  background:
    linear-gradient(90deg, rgba(36, 24, 26, 0.78), rgba(36, 24, 26, 0.18)),
    var(--hero-image),
    repeating-linear-gradient(112deg, rgba(255, 250, 244, 0.08) 0 2px, transparent 2px 58px),
    radial-gradient(circle at 82% 76%, rgba(101, 122, 70, 0.92) 0 90px, transparent 92px),
    radial-gradient(circle at 64% 66%, rgba(189, 140, 66, 0.34) 0 80px, transparent 82px),
    radial-gradient(circle at 76% 24%, rgba(255, 250, 244, 0.24) 0 16px, transparent 17px),
    radial-gradient(circle at 82% 40%, rgba(255, 250, 244, 0.16) 0 22px, transparent 23px),
    radial-gradient(circle at 70% 46%, rgba(255, 250, 244, 0.15) 0 20px, transparent 21px),
    linear-gradient(135deg, #6d1734, #657a46);
  background-position: center;
  background-size: cover;
  color: #fffaf4;
  display: grid;
  min-height: min(72vh, 680px);
  padding: clamp(30px, 8vw, 86px);
}

.hero h1 {
  max-width: 780px;
}

.hero-copy {
  color: #f2dfcf;
  font-size: clamp(1.05rem, 2.5vw, 1.45rem);
  line-height: 1.45;
  max-width: 620px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.link-button {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  text-decoration: none;
}

.public-band {
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(3, 1fr);
}

.public-band article {
  background: var(--paper);
  min-height: 220px;
  padding: clamp(22px, 5vw, 44px);
}

.public-band h2,
.login-box h2 {
  color: var(--wine);
  margin: 0 0 10px;
}

.public-band p,
.login-box p {
  color: var(--muted);
  line-height: 1.55;
}

.story-section,
.location-section {
  align-items: start;
  display: grid;
  gap: clamp(18px, 5vw, 48px);
  grid-template-columns: 0.9fr 1.1fr;
  padding: clamp(28px, 7vw, 72px) clamp(18px, 7vw, 88px);
}

.story-section {
  background: #fffaf4;
}

.story-section h2,
.location-section h2 {
  color: var(--wine);
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 1.04;
  margin: 0;
}

.story-section p,
.location-section p {
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.7;
  margin-top: 0;
}

.photo-grid {
  background: #fffaf4;
  display: grid;
  gap: clamp(12px, 2vw, 22px);
  grid-auto-rows: minmax(260px, 32vw);
  grid-template-columns: 1.2fr 0.9fr 0.9fr;
  padding: clamp(18px, 5vw, 56px);
}

.gallery-photo {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(47, 21, 28, 0.1);
  margin: 0;
  overflow: hidden;
}

.gallery-photo.large {
  grid-row: span 2;
}

.gallery-photo img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.visual-panel {
  min-height: 360px;
  overflow: hidden;
  position: relative;
}

.visual-panel.vineyard {
  background:
    linear-gradient(180deg, rgba(255, 250, 244, 0.12), rgba(36, 24, 26, 0.18)),
    repeating-linear-gradient(100deg, transparent 0 38px, rgba(255, 250, 244, 0.26) 39px 42px),
    linear-gradient(135deg, #657a46, #bd8c42);
}

.visual-panel.vineyard::before {
  background:
    radial-gradient(ellipse at center, rgba(255, 250, 244, 0.92) 0 18%, transparent 19%),
    radial-gradient(ellipse at center, rgba(255, 250, 244, 0.58) 0 17%, transparent 18%);
  background-position: 20% 38%, 70% 60%;
  background-repeat: no-repeat;
  background-size: 170px 88px, 210px 110px;
  content: "";
  height: 100%;
  inset: 0;
  position: absolute;
  width: 100%;
}

.visual-panel.bottle {
  background:
    radial-gradient(circle at 44% 22%, rgba(255, 250, 244, 0.3) 0 36px, transparent 38px),
    linear-gradient(145deg, #fffaf4, #efe5dc);
}

.visual-panel.bottle::before {
  background: linear-gradient(180deg, #f8f2e9 0 18%, #657a46 18% 28%, #fffaf4 28% 72%, #6d1734 72% 100%);
  border: 8px solid rgba(71, 17, 35, 0.2);
  border-radius: 38px 38px 16px 16px;
  box-shadow: 0 24px 50px rgba(36, 24, 26, 0.22);
  content: "";
  height: 260px;
  left: 50%;
  position: absolute;
  top: 52%;
  transform: translate(-50%, -50%);
  width: 92px;
}

.visual-panel.bottle::after {
  background: #6d1734;
  border-radius: 12px 12px 5px 5px;
  content: "";
  height: 88px;
  left: 50%;
  position: absolute;
  top: 46px;
  transform: translateX(-50%);
  width: 36px;
}

.photo-card {
  align-content: center;
  background: var(--wine);
  border-radius: 8px;
  color: #fffaf4;
  display: grid;
  padding: clamp(22px, 5vw, 44px);
}

.photo-card h2 {
  font-size: clamp(1.6rem, 4vw, 2.7rem);
  line-height: 1.03;
  margin: 0;
}

.photo-card p {
  color: #f1ddcd;
  line-height: 1.6;
}

.location-section {
  background: var(--wash);
}

.map-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--ink);
  display: grid;
  gap: 10px;
  min-height: 220px;
  padding: clamp(20px, 5vw, 38px);
  text-decoration: none;
}

.map-card strong {
  color: var(--wine);
  font-size: 1.35rem;
}

.map-card span {
  color: var(--muted);
}

.app-header::before {
  background:
    radial-gradient(circle at 68% 18%, rgba(255, 250, 244, 0.18) 0 13px, transparent 14px),
    radial-gradient(circle at 58% 34%, rgba(255, 250, 244, 0.16) 0 16px, transparent 17px),
    radial-gradient(circle at 76% 38%, rgba(255, 250, 244, 0.15) 0 17px, transparent 18px),
    radial-gradient(circle at 64% 55%, rgba(255, 250, 244, 0.13) 0 18px, transparent 19px),
    radial-gradient(circle at 82% 58%, rgba(255, 250, 244, 0.12) 0 15px, transparent 16px),
    radial-gradient(circle at 72% 76%, rgba(255, 250, 244, 0.11) 0 15px, transparent 16px);
  content: "";
  height: 160px;
  pointer-events: none;
  position: absolute;
  right: clamp(8px, 6vw, 72px);
  top: -18px;
  transform: rotate(-12deg);
  width: 180px;
}

.app-header::after {
  border-left: 3px solid rgba(255, 250, 244, 0.2);
  border-top: 3px solid rgba(255, 250, 244, 0.2);
  border-radius: 60% 0 60% 0;
  content: "";
  height: 46px;
  pointer-events: none;
  position: absolute;
  right: clamp(116px, 17vw, 192px);
  top: 20px;
  transform: rotate(26deg);
  width: 68px;
}

.app-header > div {
  position: relative;
  z-index: 1;
}

.eyebrow {
  color: #ead4bc;
  font-size: 0.78rem;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2rem, 8vw, 4.4rem);
  line-height: 0.92;
  margin: 0;
}

.icon-button {
  align-items: center;
  background: #fffaf4;
  border: 0;
  border-radius: 999px;
  color: var(--wine);
  display: grid;
  font-weight: 800;
  height: 44px;
  place-items: center;
  width: 44px;
}

.tabs {
  background: #fffaf4;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px;
  position: sticky;
  top: 0;
  z-index: 3;
}

.tab {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  min-height: 42px;
  padding: 8px 6px;
}

.tab.active {
  background: var(--wine);
  color: white;
}

main {
  margin: 0 auto;
  max-width: 1120px;
  padding: clamp(14px, 4vw, 30px);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.toolbar,
.line-editor,
.stacked-form {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
  padding: 16px;
}

.section-head {
  align-items: end;
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr minmax(220px, 340px);
  margin-bottom: 16px;
}

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

.eyebrow.dark {
  color: var(--wine);
}

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

.line-editor {
  grid-template-columns: 2fr 1fr 0.8fr 1fr auto;
}

.stacked-form {
  box-shadow: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stacked-form label:has(textarea),
.stacked-form button {
  grid-column: 1 / -1;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 0.82rem;
  gap: 6px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid #dacdca;
  border-radius: 6px;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 10px;
  width: 100%;
}

textarea {
  resize: vertical;
}

button {
  cursor: pointer;
}

.primary,
.secondary,
.danger {
  border: 0;
  border-radius: 6px;
  min-height: 42px;
  padding: 10px 14px;
}

.primary {
  background: var(--wine);
  color: white;
  font-weight: 700;
}

.secondary {
  background: #efe5dc;
  color: var(--wine-dark);
}

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

.table-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 620px;
  width: 100%;
}

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

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

.totals {
  background: var(--wine-dark);
  border-radius: 8px;
  color: white;
  margin: 16px 0;
  margin-left: auto;
  max-width: 420px;
  padding: 16px;
}

.totals div {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
}

.totals .grand {
  border-top: 1px solid rgba(255, 255, 255, 0.28);
  color: #ffe0aa;
  font-size: 1.2rem;
  margin-top: 6px;
  padding-top: 14px;
}

.actions {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.view-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr 1fr;
}

.invoice-view {
  display: none;
}

.invoice-view.active {
  display: block;
}

.invoice-list {
  display: grid;
  gap: 10px;
}

.invoice-row {
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1.3fr 0.7fr 0.7fr auto;
  padding: 12px;
}

.invoice-row span {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.invoice-row .doc-kind {
  background: #efe5dc;
  border-radius: 999px;
  color: var(--wine);
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  margin: 0 0 6px;
  padding: 4px 8px;
  text-transform: uppercase;
}

.invoice-row menu {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin: 0;
  padding: 0;
}

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

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.card h3 {
  margin: 0 0 5px;
}

.card p {
  color: var(--muted);
  margin: 4px 0;
  white-space: pre-line;
}

.card menu {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
}

.empty-state {
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  margin: 0;
  padding: 16px;
}

.logo-preview {
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  justify-content: center;
  min-height: 92px;
  padding: 12px;
}

.logo-preview img {
  max-height: 84px;
  max-width: 180px;
  object-fit: contain;
}

.logo-preview.empty {
  border-style: dashed;
}

.file-field input {
  padding: 8px;
}

dialog {
  border: 0;
  border-radius: 8px;
  max-width: 900px;
  padding: 0;
  width: min(94vw, 900px);
}

dialog::backdrop {
  background: rgba(30, 14, 19, 0.56);
}

.invoice-document {
  background: white;
  color: #161616;
  padding: clamp(18px, 4vw, 42px);
}

.invoice-head {
  align-items: start;
  border-bottom: 3px solid var(--wine);
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr 1fr;
  padding-bottom: 24px;
}

.invoice-company {
  display: flex;
  gap: 18px;
}

.invoice-logo {
  max-height: 86px;
  max-width: 140px;
  object-fit: contain;
}

.invoice-document h2 {
  color: var(--wine);
  font-size: 2rem;
  margin: 0 0 10px;
}

.invoice-meta {
  text-align: right;
}

.invoice-document table {
  margin: 28px 0;
  min-width: 0;
}

.invoice-document .summary {
  margin-left: auto;
  max-width: 340px;
}

.invoice-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  margin-top: 28px;
  padding-top: 14px;
}

.dialog-actions {
  background: #f3ece6;
  padding: 12px;
  text-align: right;
}

.dialog-actions.plain {
  background: transparent;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 0;
}

.login-box {
  background: var(--paper);
  display: grid;
  gap: 14px;
  max-width: 420px;
  padding: 22px;
}

.form-error {
  color: var(--danger);
  margin: 0;
  min-height: 20px;
}

.toast {
  background: var(--leaf);
  border-radius: 6px;
  bottom: 18px;
  color: white;
  left: 50%;
  padding: 10px 14px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 10;
}

@media (max-width: 760px) {
  .app-header {
    min-height: 100px;
  }

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

  .site-nav,
  .hero-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .public-band {
    grid-template-columns: 1fr;
  }

  .story-section,
  .location-section,
  .photo-grid {
    grid-template-columns: 1fr;
  }

  .photo-grid {
    grid-auto-rows: auto;
  }

  .gallery-photo,
  .gallery-photo.large {
    grid-row: auto;
    min-height: 260px;
  }

  .visual-panel {
    min-height: 260px;
  }

  .toolbar,
  .line-editor,
  .stacked-form,
  .actions,
  .section-head,
  .view-actions,
  .invoice-row {
    grid-template-columns: 1fr;
  }

  .invoice-row menu {
    justify-content: stretch;
  }

  .invoice-row menu button {
    flex: 1 1 130px;
  }

  .totals {
    max-width: none;
  }

  .invoice-head {
    grid-template-columns: 1fr;
  }

  .invoice-company {
    flex-direction: column;
  }

  .invoice-meta {
    text-align: left;
  }
}

@media print {
  body * {
    visibility: hidden;
  }

  #invoicePreview,
  #invoicePreview * {
    visibility: visible;
  }

  #invoicePreview {
    inset: 0;
    position: absolute;
  }
}
