:root {
  --green-900: #1f3b2c;
  --green-700: #2f5d3f;
  --green-600: #3c7a4f;
  --green-100: #eaf3ea;
  --earth-50: #fbf9f4;
  --earth-100: #f4efe4;
  --border: #e0dccf;
  --text: #2a2620;
  --text-muted: #7a7469;
  --danger: #b3402a;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--earth-50);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 100px;
}

.app-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.app-header h1 {
  font-size: 1.4rem;
  margin: 0;
  color: var(--green-900);
}

.link-btn {
  background: none;
  border: none;
  color: var(--green-700);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px;
  text-decoration: none;
}
.link-btn:hover { text-decoration: underline; }

.discount-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 0 0 16px;
}

.status {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 0;
}

.items {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.item-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "desc  desc desc"
    "price qty  total";
  align-items: center;
  row-gap: 8px;
  column-gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.item-row:last-child { border-bottom: none; }

@media (min-width: 560px) {
  .item-row {
    grid-template-columns: 1fr 62px 108px 92px;
    grid-template-areas: "desc price qty total";
    row-gap: 0;
    padding: 10px 12px;
  }
}

.item-row--section-break {
  border-top: 10px solid var(--earth-50);
}

.group-title {
  padding: 16px 12px 8px;
  margin-top: 10px;
  border-top: 10px solid var(--earth-50);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--green-900);
  letter-spacing: 0.01em;
  background: #fff;
}
.group-title::after {
  content: "";
  display: block;
  width: 32px;
  height: 3px;
  margin-top: 6px;
  background: var(--green-600);
  border-radius: 2px;
}
.group-title--first {
  margin-top: 0;
  border-top: none;
  padding-top: 14px;
}

.item-row--head {
  display: none;
  background: var(--green-100);
  color: var(--green-900);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
  padding: 8px 12px;
}
@media (min-width: 560px) {
  .item-row--head { display: grid; }
}

.item-desc {
  grid-area: desc;
  font-size: 0.92rem;
  line-height: 1.3;
}

.item-price {
  grid-area: price;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: left;
}
@media (min-width: 560px) {
  .item-price { text-align: right; }
}

.item-qty {
  grid-area: qty;
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
}

.qty-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--earth-100);
  color: var(--green-900);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qty-btn:hover { background: var(--green-100); }
.qty-btn:active { transform: scale(0.95); }

.qty-input {
  width: 40px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 2px;
  font-size: 0.9rem;
}

.item-linetotal {
  grid-area: total;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--green-900);
}

.discount-badge {
  order: -1;
  font-size: 0.66rem;
  font-weight: 700;
  color: #fff;
  background: var(--green-600);
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.4;
}

.linetotal-orig {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  text-decoration: line-through;
}

.linetotal-net {
  font-weight: 700;
}

.savings-note {
  text-align: center;
  color: var(--green-700);
  font-size: 0.85rem;
  font-weight: 600;
  margin: 10px 0 0;
}

.summary-bar {
  position: sticky;
  bottom: 0;
  margin-top: 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}

.summary-bar-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.summary-bar-total {
  margin-left: auto;
  font-size: 0.95rem;
}
.summary-bar-total strong { color: var(--green-900); }

.primary-btn {
  background: var(--green-600);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.primary-btn:hover:not(:disabled) { background: var(--green-700); }
.primary-btn:disabled { background: #b9c6bb; cursor: not-allowed; }
.primary-btn--full { width: 100%; margin-top: 16px; }

/* Modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal[hidden] {
  display: none;
}
@media (min-width: 560px) {
  .modal { align-items: center; }
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 15, 0.45);
}

.modal-panel {
  position: relative;
  background: #fff;
  border-radius: 14px 14px 0 0;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px 20px 28px;
}
@media (min-width: 560px) {
  .modal-panel { border-radius: 14px; }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--earth-100);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}
.modal-close:hover { background: var(--green-100); color: var(--green-900); }

#modalTitle {
  margin: 0 0 12px;
  color: var(--green-900);
  font-size: 1.2rem;
}

.order-summary {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  max-height: 160px;
  overflow-y: auto;
  background: var(--earth-100);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  padding: 3px 0;
}

.order-summary-total {
  text-align: right;
  margin: 10px 0 18px;
  font-size: 0.95rem;
}
.order-summary-total strong { color: var(--green-900); }

.hp-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
  height: 0;
  width: 0;
  overflow: hidden;
}

#orderForm label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 14px 0 6px;
  color: var(--green-900);
}
#orderForm label .req { color: var(--danger); }
#orderForm label .opt { color: var(--text-muted); font-weight: 400; }

#orderForm input,
#orderForm textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 0.92rem;
  font-family: inherit;
}
#orderForm input:focus,
#orderForm textarea:focus {
  outline: 2px solid var(--green-600);
  outline-offset: 1px;
}

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 12px;
}

.success-panel {
  text-align: center;
  padding: 20px 0 4px;
}
.success-panel p { margin: 6px 0; }
.success-panel .primary-btn { margin-top: 16px; }

body.modal-open { overflow: hidden; }
