:root {
  /* Colours taken from the Rose & Robin logo */
  --ink: #2b2a22;
  --paper: #fbf7ec;        /* logo cream */
  --card: #fffefa;
  --bottle: #46632f;       /* logo forest green (text, headings, bars) */
  --marigold: #c95f14;     /* robin's breast orange (buttons) */
  --marigold-dark: #a94e0e;
  --sage: #5d8a45;         /* leaf green */
  --rust: #b8394f;         /* deep rose (alerts / low stock) */
  --rose: #e39aa4;         /* rose pink (accents) */
  --rose-soft: #f9e4e6;
  --leaf-soft: #e8f0dd;
  --line: #e6dcc3;
  --radius: 12px;
  --serif: Georgia, "Palatino Linotype", "Book Antiqua", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background-image:
    radial-gradient(circle at 0% 0%, var(--rose-soft) 0, transparent 38%),
    radial-gradient(circle at 100% 100%, var(--leaf-soft) 0, transparent 40%);
  background-attachment: fixed;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bottle);
  color: var(--paper);
  border-bottom: 4px solid var(--rose);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo img {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 2px solid var(--paper);
  background: var(--paper);
}

.topbar-actions { display: flex; gap: 6px; }

.brand {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 700;
  font-style: italic;
  letter-spacing: 0.01em;
  margin: 0;
}

.link-btn {
  background: none;
  border: none;
  color: inherit;
  text-decoration: underline;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 6px;
}

.topbar .link-btn { color: var(--paper); opacity: 0.85; }
.topbar .link-btn:hover { opacity: 1; }

.layout {
  display: flex;
  gap: 16px;
  padding: 16px;
  align-items: flex-start;
}

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.product-tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  font: inherit;
  color: inherit;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.product-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--rose-soft);
}

.product-photo.blank {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 2.4rem;
  font-style: italic;
  color: var(--rose);
  background: linear-gradient(135deg, var(--rose-soft), var(--leaf-soft));
}

.product-body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  padding: 10px 12px 12px;
}

.product-tile:active { transform: scale(0.97); }

.product-tile:hover {
  box-shadow: 0 3px 0 var(--rose);
  border-color: var(--rose);
}

.product-tile.out {
  opacity: 0.45;
  cursor: not-allowed;
}

.product-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.25;
}

.product-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 8px;
  font-size: 0.9rem;
}

.product-price { font-weight: 700; color: var(--bottle); }
.product-stock { color: var(--sage); }
.product-stock.low { color: var(--rust); }

.basket {
  width: 300px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 16px;
}

.basket h2 {
  font-family: var(--serif);
  color: var(--bottle);
  margin: 0 0 10px;
  font-size: 1.1rem;
}

.basket-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 40vh;
  overflow-y: auto;
}

.basket-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  gap: 8px;
}

.basket-item-name { flex: 1; font-size: 0.92rem; }

.qty-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qty-controls button {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.basket-empty {
  color: #8a8271;
  font-size: 0.9rem;
  margin: 10px 0;
}

.basket-total-row {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.15rem;
  padding-top: 12px;
  margin-top: 8px;
  border-top: 2px solid var(--bottle);
}

.primary-btn {
  width: 100%;
  margin-top: 14px;
  background: var(--marigold);
  color: var(--paper);
  border: none;
  padding: 14px;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

.primary-btn:hover:not(:disabled) { background: var(--marigold-dark); }

.primary-btn:disabled {
  background: #d8d0bb;
  cursor: not-allowed;
}

.primary-btn.small { padding: 10px; font-size: 0.95rem; margin-top: 0; width: auto; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(33, 29, 22, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.modal-backdrop:not([hidden]) {
  display: flex;
}

.modal {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal.wide { max-width: 720px; }

.modal h2 { margin-top: 0; font-family: var(--serif); color: var(--bottle); }

.modal-total {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--bottle);
  margin: 4px 0 18px;
}

.method-choice {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.method-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  text-align: left;
}

.method-btn:hover { border-color: var(--rose); background: var(--rose-soft); }
.method-btn strong { font-size: 1.02rem; }
.method-btn span { font-size: 0.85rem; color: #6b6353; }

.method-status {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eee7d3;
  font-size: 0.92rem;
}

.method-status.success { background: var(--leaf-soft); color: var(--bottle); }
.method-status.error { background: var(--rose-soft); color: var(--rust); }

.qr-area {
  margin-top: 16px;
  text-align: center;
}

.qr-area p { font-size: 0.85rem; color: #6b6353; }

.stock-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 0.92rem;
}

.stock-table th, .stock-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}

.stock-table input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 0.9rem;
}

.stock-table .del-btn {
  background: none;
  border: none;
  color: var(--rust);
  cursor: pointer;
  font-size: 0.85rem;
}

.add-product-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.add-product-form input {
  flex: 1;
  min-width: 100px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bottle);
  color: var(--paper);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.95rem;
  z-index: 20;
}

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .basket { width: 100%; position: static; }
}


/* ---- Customer details form (shared by till + customer page) ---- */
.details-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.details-form label { font-size: 0.85rem; font-weight: 600; color: var(--bottle); }
.details-form input[type="text"], .details-form input[type="email"], .details-form input[type="tel"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-size: 1rem;
  background: #fff;
}
.details-form input:focus { outline: 2px solid var(--rose); border-color: var(--rose); }
.contact-choice { display: flex; gap: 8px; }
.contact-choice label {
  flex: 1;
  text-align: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
  font-weight: 600;
}
.contact-choice input { display: none; }
.contact-choice label:has(input:checked) { background: var(--bottle); color: var(--paper); border-color: var(--bottle); }
.form-error { color: var(--rust); background: var(--rose-soft); border-radius: 8px; padding: 8px 10px; font-size: 0.9rem; margin: 0; }
.privacy-note { font-size: 0.78rem; color: #6b6353; margin: 0; line-height: 1.4; }

/* ---- Stock table photos ---- */
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--rose-soft); display: block; }
.photo-cell { display: flex; align-items: center; gap: 8px; }
.photo-btn { font-size: 0.8rem; color: var(--bottle); text-decoration: underline; cursor: pointer; background: none; border: none; padding: 0; }
.photo-btn input { display: none; }

/* ---- Sales log ---- */
.sales-list { list-style: none; margin: 0 0 12px; padding: 0; }
.sales-list li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.sales-list .sale-top { display: flex; justify-content: space-between; font-weight: 700; }
.sales-list .sale-sub { color: #6b6353; margin-top: 2px; }

.sales-search { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 1rem; margin-bottom: 8px; }
.sales-list li[hidden] { display: none; }

/* Sticky header with a close (X) button for the admin popups */
.modal-head {
  position: sticky;
  top: -24px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -24px -24px 12px;
  padding: 16px 24px 10px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; }
.close-x {
  width: 40px; height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--bottle);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.close-x:hover { background: var(--rose-soft); border-color: var(--rose); }

.danger-link { color: var(--rust); float: right; }

#exportSales { color: var(--bottle); text-decoration: underline; margin-right: 8px; }
