:root {
  --ink: #1f3d37;
  --evergreen: #2f5a50;
  --sage: #d8e4d2;
  --ivory: #f7f3ea;
  --warm-white: #fffaf0;
  --lime: #d8ff68;
  --cyan: #36d6c9;
  --line: rgba(31, 61, 55, 0.18);
  --muted: #5c6a64;
  --shadow: 0 22px 70px rgba(47, 90, 80, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 0%, rgba(54, 214, 201, 0.28), transparent 25rem),
    linear-gradient(135deg, var(--warm-white), var(--ivory) 54%, var(--sage));
  font-family: Inter, Arial, sans-serif;
}

.access-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 86% 12%, rgba(54, 214, 201, 0.28), transparent 24rem),
    linear-gradient(135deg, var(--warm-white), var(--ivory) 55%, var(--sage));
}

.access-panel {
  width: min(520px, 100%);
  padding: clamp(28px, 5vw, 44px);
  background: rgba(255, 250, 240, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.access-panel img {
  width: min(300px, 78vw);
  height: auto;
}

.access-panel p,
.quote-archive p {
  margin: 24px 0 8px;
  color: #168e86;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.access-panel h1 {
  margin: 0 0 22px;
  font-family: "Space Grotesk", Inter, Arial, sans-serif;
  font-size: clamp(2rem, 6vw, 3.5rem);
  line-height: 0.98;
}

.access-panel .primary-action {
  width: 100%;
  margin-top: 14px;
}

.access-back {
  display: inline-flex;
  justify-content: center;
  width: 100%;
  margin-top: 12px;
  color: var(--evergreen);
  font-weight: 900;
  text-decoration: none;
}

#accessMessage {
  display: block;
  min-height: 22px;
  margin-top: 12px;
  color: #a14343;
  font-weight: 800;
}

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

.quote-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 78px;
  padding: 14px clamp(18px, 4vw, 54px);
  background: rgba(255, 250, 240, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.quote-brand img {
  display: block;
  width: clamp(170px, 18vw, 250px);
  height: auto;
}

.toolbar-actions,
.items-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-action,
.secondary-action {
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.primary-action {
  background: var(--lime);
}

.secondary-action {
  background: rgba(255, 250, 240, 0.8);
  border-color: var(--line);
}

.quote-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: clamp(28px, 5vw, 64px) 0;
}

.quote-intro {
  display: grid;
  gap: 10px;
  max-width: 920px;
  margin-bottom: 28px;
}

.quote-archive {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding: 18px;
  background: rgba(255, 250, 240, 0.76);
  border: 1px solid var(--line);
}

.quote-archive p {
  margin-top: 0;
}

.quote-archive span {
  color: var(--muted);
  font-weight: 700;
}

.archive-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.archive-list button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--warm-white);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.quote-intro p {
  margin: 0;
  color: #168e86;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.quote-intro h1 {
  margin: 0;
  font-family: "Space Grotesk", Inter, Arial, sans-serif;
  font-size: clamp(2.1rem, 5vw, 4.6rem);
  line-height: 0.98;
}

.quote-intro span {
  max-width: 760px;
  color: rgba(31, 61, 55, 0.72);
  font-size: 1.05rem;
}

.quote-document {
  padding: clamp(24px, 4vw, 46px);
  background: rgba(255, 250, 240, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.document-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 4px solid var(--lime);
}

.document-head img {
  width: min(340px, 48vw);
  height: auto;
}

.document-head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.quote-title {
  display: grid;
  gap: 12px;
  min-width: 220px;
  text-align: right;
}

.quote-title strong {
  font-family: "Space Grotesk", Inter, Arial, sans-serif;
  font-size: 2.4rem;
  line-height: 1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--evergreen);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 8px 10px;
}

textarea {
  min-height: 96px;
  padding: 10px;
  resize: vertical;
}

.quote-meta {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 14px;
  margin: 24px 0;
}

.quote-meta label:nth-child(1),
.quote-meta label:nth-child(2) {
  grid-column: span 2;
}

.items-actions {
  margin-bottom: 14px;
}

.quote-table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(31, 61, 55, 0.28);
  border-top: 5px solid var(--lime);
  background: #fff;
}

.quote-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  background: #fff;
}

.quote-table th {
  padding: 15px 12px;
  background: var(--ink);
  color: var(--warm-white);
  border-right: 1px solid rgba(255, 250, 240, 0.18);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.12;
  text-transform: uppercase;
}

.quote-table td {
  padding: 12px;
  border-top: 1px solid rgba(31, 61, 55, 0.16);
  border-right: 1px solid rgba(31, 61, 55, 0.16);
  vertical-align: middle;
}

.description-col {
  width: 31%;
}

.image-col {
  width: 18%;
}

.description-cell textarea {
  min-height: 132px;
  border: 0;
  background: transparent;
  font-size: 1rem;
  line-height: 1.35;
}

.image-cell {
  min-width: 190px;
  text-align: center;
}

.image-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.image-picker,
.paste-image {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
}

.image-picker {
  border: 1px dashed rgba(31, 61, 55, 0.36);
  border-radius: 10px;
  background: var(--ivory);
  cursor: pointer;
}

.paste-image {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--lime);
  cursor: pointer;
}

.paste-image:focus-visible {
  outline: 3px solid rgba(54, 214, 201, 0.45);
  outline-offset: 2px;
}

.image-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.paste-target {
  display: none;
  margin-top: 8px;
  padding: 10px;
  border: 2px dashed rgba(31, 61, 55, 0.32);
  border-radius: 10px;
  background: rgba(216, 228, 210, 0.42);
  color: var(--evergreen);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
  outline: none;
}

.paste-target.is-active {
  display: block;
}

.paste-target:focus {
  border-color: var(--cyan);
  background: rgba(54, 214, 201, 0.12);
}

.paste-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: none;
}

.paste-status {
  display: block;
  min-height: 18px;
  margin-top: 6px;
  color: #168e86;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: none;
}

.paste-status.is-error {
  color: #a14343;
}

.item-image {
  display: none;
  width: 160px;
  height: 118px;
  margin: 8px auto;
  object-fit: contain;
  border: 1px solid var(--line);
  background: var(--warm-white);
}

.item-image.has-image {
  display: block;
}

.text-action {
  border: 0;
  background: transparent;
  color: #168e86;
  font-weight: 800;
  cursor: pointer;
}

.item-qty,
.item-price {
  min-width: 96px;
  text-align: right;
}

.money {
  min-width: 118px;
  text-align: right;
  font-weight: 800;
  white-space: nowrap;
}

.item-qty,
.item-price,
.money {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.row-action-col {
  width: 84px;
}

.delete-row {
  border: 0;
  background: transparent;
  color: #a14343;
  font-weight: 900;
  cursor: pointer;
}

.quote-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  margin-top: 24px;
}

.notes-field textarea {
  min-height: 150px;
}

.totals-panel {
  align-self: start;
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--line);
}

.totals-panel div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  background: #fff;
}

.totals-panel span {
  color: var(--muted);
  font-weight: 800;
}

.totals-panel strong {
  font-size: 1.2rem;
}

.totals-panel .grand-total {
  background: var(--lime);
}

.totals-panel .grand-total span,
.totals-panel .grand-total strong {
  color: var(--ink);
}

.quote-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--evergreen);
  font-weight: 900;
}

@media (max-width: 980px) {
  .quote-toolbar,
  .document-head,
  .quote-bottom {
    align-items: stretch;
    flex-direction: column;
  }

  .document-head,
  .quote-bottom {
    display: grid;
    grid-template-columns: 1fr;
  }

  .quote-title {
    text-align: left;
  }

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

  .quote-meta label:nth-child(1),
  .quote-meta label:nth-child(2) {
    grid-column: span 2;
  }
}

@media (max-width: 620px) {
  .quote-shell {
    width: min(100vw - 18px, 1480px);
  }

  .quote-meta {
    grid-template-columns: 1fr;
  }

  .quote-meta label:nth-child(1),
  .quote-meta label:nth-child(2) {
    grid-column: span 1;
  }

  .toolbar-actions,
  .items-actions {
    display: grid;
  }
}

@media print {
  @page {
    size: letter landscape;
    margin: 7mm;
  }

  body {
    background: #fff;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .no-print,
  .quote-toolbar,
  .quote-intro,
  .row-action-col {
    display: none !important;
  }

  .quote-shell {
    width: 100%;
    padding: 0;
  }

  .quote-document {
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .document-head {
    display: grid;
    grid-template-columns: 1fr 210px;
    gap: 12px;
    padding-bottom: 6px;
    border-bottom-width: 3px;
  }

  .document-head img {
    width: 220px;
  }

  .document-head p {
    margin-top: 3px;
    font-size: 10px;
  }

  .quote-title {
    min-width: 0;
    gap: 5px;
  }

  .quote-title strong {
    font-size: 24px;
  }

  label {
    gap: 3px;
    font-size: 8px;
  }

  .quote-meta {
    grid-template-columns: 1.4fr 1.6fr 0.8fr 0.8fr 0.55fr 0.65fr;
    gap: 8px;
    margin: 8px 0;
  }

  .quote-meta label:nth-child(1),
  .quote-meta label:nth-child(2) {
    grid-column: span 1;
  }

  input,
  select,
  textarea {
    border: 0;
    padding: 0;
    background: transparent;
  }

  textarea {
    resize: none;
  }

  .quote-table-wrap {
    overflow: visible;
  }

  .quote-table {
    min-width: 0;
    table-layout: fixed;
    font-size: 9px;
  }

  .quote-table th {
    padding: 8px 5px 6px;
    background: #fff !important;
    color: var(--ink) !important;
    border-top: 4px solid var(--ink);
    border-bottom: 3px solid var(--lime);
    border-right: 1px solid rgba(31, 61, 55, 0.24);
    font-size: 8.5px;
    font-weight: 900;
    letter-spacing: 0.04em;
  }

  .quote-table td {
    padding: 6px 5px;
  }

  .description-col {
    width: 28%;
  }

  .image-col {
    width: 16%;
  }

  .description-cell textarea {
    min-height: 48px;
    font-size: 9px;
    line-height: 1.2;
  }

  .item-qty,
  .item-price {
    min-width: 0;
  }

  .money {
    min-width: 0;
  }

  .item-image {
    display: block;
    width: 82px;
    height: 58px;
  }

  .item-image:not(.has-image) {
    display: none;
  }

  .quote-bottom {
    grid-template-columns: 1fr 230px;
    gap: 10px;
    margin-top: 10px;
    page-break-inside: avoid;
  }

  .notes-field textarea {
    min-height: 56px;
    font-size: 9px;
  }

  .totals-panel div {
    padding: 7px 9px;
  }

  .totals-panel strong {
    font-size: 12px;
  }

  .quote-footer {
    margin-top: 10px;
    padding-top: 8px;
    font-size: 9px;
  }
}
