:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  --brand-primary: #0f5c4a;
  --brand-accent: #9d1f1f;
  --brand-bg: #f6f7f4;
  --brand-text: #172018;
  background: var(--brand-bg);
  color: var(--brand-text);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

a {
  color: var(--brand-primary);
  font-weight: 700;
  text-decoration: none;
}

button, input, select {
  border: 1px solid #aab3aa;
  border-radius: 6px;
  font: inherit;
  min-height: 42px;
}

button {
  background: var(--brand-primary);
  color: white;
  cursor: pointer;
  padding: 0 14px;
}

input, select {
  background: white;
  padding: 8px 10px;
  width: 100%;
}

h1, h2, p {
  margin-top: 0;
}

.hidden {
  display: none;
}

.topbar {
  align-items: center;
  background: white;
  border-bottom: 1px solid #d7ddd5;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 14px 24px;
}

.brand {
  color: var(--brand-text);
  font-size: 20px;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.page {
  margin: 0 auto;
  max-width: 1120px;
  padding: 28px 20px;
}

.login-box {
  background: white;
  border: 1px solid #d7ddd5;
  border-radius: 8px;
  margin: 40px auto;
  max-width: 440px;
  padding: 22px;
}

.form {
  display: grid;
  gap: 12px;
}

.form.inline {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 24px;
}

.grid-inline-form {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.bill-form {
  margin-bottom: 24px;
}

.supplier-contact-row {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.delivery-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.bill-lines {
  display: grid;
  gap: 12px;
}

.bill-lines h2 {
  margin: 0;
}

.bill-total {
  font-size: 20px;
}

.settings-form {
  background: white;
  border: 1px solid #d7ddd5;
  border-radius: 8px;
  display: grid;
  gap: 14px;
  padding: 18px;
}

.settings-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin: 18px 0;
}

.setup-message {
  background: #eef3ed;
  border-radius: 8px;
  color: var(--brand-text);
  min-height: 0;
  padding: 10px 12px;
}

.setup-message:empty {
  display: none;
}

.settings-form h2 {
  border-top: 1px solid #d7ddd5;
  margin: 10px 0 0;
  padding-top: 18px;
}

.settings-form h2:first-child {
  border-top: 0;
  padding-top: 0;
}

.token-row, .user-row, .card-machine-row {
  display: grid;
  gap: 10px;
}

.token-row {
  grid-template-columns: 1.2fr 1.2fr auto auto;
}

.user-row {
  grid-template-columns: 1.2fr 1.5fr 1.2fr 1fr auto auto;
}

.card-machine-row {
  align-items: center;
  grid-template-columns: 1.2fr 1.8fr auto auto;
}

.card-machine-row small {
  color: #536058;
}

.sumup-pairing {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr auto;
}

.sumup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.check {
  align-items: center;
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.check input {
  min-height: auto;
  width: auto;
}

.form.inline button {
  min-width: 140px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.grid-actions {
  grid-column: 1 / -1;
}

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

.product-grid-form h2 {
  grid-column: 1 / -1;
}

.checkbox-row {
  align-items: center;
  display: flex;
  gap: 10px;
}

.checkbox-row input {
  width: auto;
}

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

.summary-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 28px;
}

.summary {
  background: white;
  border: 1px solid #d7ddd5;
  border-left: 5px solid var(--brand-primary);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 16px;
}

.summary strong {
  font-size: 24px;
}

.line-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.line-list li, .table-row {
  align-items: center;
  background: white;
  border-bottom: 1px solid #e2e7e0;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 13px 12px;
}

.table {
  border: 1px solid #d7ddd5;
  border-radius: 8px;
  margin-top: 18px;
  overflow: hidden;
}

.table-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
}

#stockTable .product-row {
  grid-template-columns: 1.5fr 1fr 0.8fr 1fr 0.9fr 0.9fr 0.7fr 0.8fr 1.2fr 1fr;
}

.table-header {
  background: #eef3ed;
  font-weight: 700;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.row-actions button {
  min-height: 36px;
}

.audit-dialog {
  display: grid;
  gap: 12px;
}

.audit-list {
  display: grid;
  gap: 10px;
  max-height: 60vh;
  overflow: auto;
}

.audit-entry {
  background: white;
  border: 1px solid #d7ddd5;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 12px;
}

.audit-entry small {
  color: #536058;
}

.member-invoice-option {
  align-items: start;
  grid-template-columns: auto 1fr auto;
}

.member-invoice-option input {
  margin-top: 4px;
}

.member-invoice-total {
  align-items: center;
  grid-template-columns: 1fr auto auto;
}

.stock-take-row {
  grid-template-columns: 2fr 1fr 2fr;
}

.bill-line-row {
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
}

.modal {
  border: 1px solid #d7ddd5;
  border-radius: 8px;
  max-width: 760px;
  padding: 22px;
  width: min(760px, 92vw);
}

.modal::backdrop {
  background: rgb(23 32 24 / 55%);
}

.transactions-row {
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr auto;
}

.product-row[data-product-row] {
  cursor: pointer;
}

.preview-invoice-row {
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
  width: 100%;
}

.tab-item-row {
  grid-template-columns: 2fr 1fr 1fr auto;
}

.product-history-table .table-row {
  grid-template-columns: 1.2fr 0.7fr 1.2fr 2fr;
}

.product-history-summary {
  margin-bottom: 16px;
}

.report-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr 1fr;
}

.low {
  color: var(--brand-accent);
  font-weight: 700;
}

pre {
  background: var(--brand-text);
  border-radius: 8px;
  color: #e8f4e8;
  overflow: auto;
  padding: 14px;
}

.pos-page {
  height: 100dvh;
  overflow: hidden;
  padding: 14px;
}

.pos-shell {
  height: 100%;
}

.pos-step {
  height: calc(100dvh - 86px);
  overflow: hidden;
}

.pos-brand-banner {
  align-items: center;
  background: var(--brand-primary);
  border-radius: 8px;
  color: white;
  display: flex;
  font-size: 26px;
  font-weight: 700;
  height: 58px;
  justify-content: center;
  margin-bottom: 10px;
  padding: 0 18px;
}

.pos-layout {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(300px, 34%) 1fr;
}

.step-bar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
  margin-bottom: 10px;
}

.step-bar h1 {
  margin: 0;
  text-align: center;
}

.compact-bar h1 {
  font-size: 22px;
  text-align: left;
}

.back-button {
  background: white;
  color: var(--brand-text);
}

.choice-grid {
  align-content: center;
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-content: center;
  padding: 8vh 6vw;
  position: relative;
}

.pos-choice.hidden,
.pos-member-picker.hidden,
.pos-layout.hidden,
.pos-history.hidden,
.pos-complete.hidden {
  display: none;
}

.history-edge-button {
  bottom: 0;
  font-size: 14px;
  min-height: 38px;
  opacity: 0.9;
  position: absolute;
  right: 10px;
}

.history-edge-button-left {
  left: 10px;
  right: auto;
}

.pos-history {
  display: grid;
  grid-template-rows: auto 1fr;
}

.history-list {
  list-style: none;
  margin: 0 auto;
  max-width: 760px;
  overflow: hidden;
  padding: 0;
  width: min(760px, 94vw);
}

.history-list li {
  align-items: center;
  background: white;
  border-bottom: 1px solid #d7ddd5;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px;
}

.pos-complete {
  align-items: center;
  display: grid;
  justify-items: center;
  text-align: center;
}

.pos-complete > div {
  background: white;
  border: 1px solid #d7ddd5;
  border-radius: 8px;
  display: grid;
  gap: 18px;
  max-width: 680px;
  padding: 34px;
  width: min(680px, 92vw);
}

.pos-complete h1 {
  font-size: 42px;
  line-height: 1.1;
  margin: 0;
}

.pos-complete p {
  font-size: 22px;
  margin: 0;
}

.countdown-line strong {
  color: var(--brand-primary);
  font-size: 34px;
}

.complete-lines {
  list-style: none;
  margin: 0;
  max-height: 28vh;
  max-width: none;
  overflow: hidden;
  padding: 0;
  width: 100%;
}

.complete-lines li {
  border-bottom: 1px solid #d7ddd5;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 10px 0;
  text-align: left;
}

.complete-lines strong {
  color: var(--brand-text);
  font-size: 18px;
  white-space: nowrap;
}

.complete-total {
  border-bottom: 0;
  font-weight: 700;
  padding-top: 14px;
}

.complete-status strong {
  color: var(--brand-accent);
}

.complete-total strong {
  color: var(--brand-primary);
  font-size: 22px;
}

.complete-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

#printReceipt, #newTransaction {
  font-size: 20px;
  min-height: 58px;
  min-width: 220px;
}

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

.choice-button, .member-card {
  background: white;
  color: var(--brand-text);
  min-height: 118px;
  padding: 18px;
  text-align: left;
}

.choice-button {
  border: 2px solid var(--brand-primary);
  font-size: 32px;
  font-weight: 700;
  min-height: 42vh;
  text-align: center;
}

.member-card {
  display: grid;
  gap: 6px;
  min-height: 88px;
  padding: 12px;
}

.member-card strong {
  font-size: 17px;
  line-height: 1.15;
}

.member-card span {
  color: #536058;
  font-size: 13px;
}

.member-card small {
  color: #a43b27;
  display: block;
  font-weight: 700;
  margin-top: 3px;
}

.temporary-tab-button {
  margin-bottom: 12px;
  min-height: 54px;
  width: 100%;
}

.scroll-grid {
  max-height: calc(100% - 130px);
  overflow: hidden;
  padding-right: 4px;
}

.till-side {
  background: white;
  border: 1px solid #d7ddd5;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-rows: auto auto minmax(0, 1fr) auto minmax(0, 1fr);
  min-height: 0;
  padding: 12px;
}

.product-grid {
  display: grid;
  gap: 10px;
  grid-auto-rows: minmax(0, 1fr);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  height: calc(100% - 54px);
}

.product {
  background: white;
  color: var(--brand-text);
  display: grid;
  gap: 8px;
  min-height: 0;
  padding: 14px;
  text-align: left;
}

.category-tile {
  align-content: center;
  text-align: center;
}

.category-tile strong {
  font-size: 22px;
}

.product small {
  color: var(--brand-primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.product span {
  color: #536058;
}

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

.mixer-grid button {
  min-height: 64px;
}

.total-bar {
  border-top: 1px solid #d7ddd5;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding-top: 10px;
}

.total-bar strong {
  align-self: center;
  font-size: 24px;
  grid-column: 1 / -1;
}

.items-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}

.category-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  margin-bottom: 10px;
}

.category-chip {
  background: white;
  color: var(--brand-text);
  font-weight: 700;
}

.category-chip.active {
  background: var(--brand-primary);
  color: white;
}

.product-grid-empty {
  align-items: center;
  background: white;
  border: 1px dashed #d7ddd5;
  border-radius: 8px;
  color: #536058;
  display: grid;
  grid-column: 1 / -1;
  justify-items: center;
  min-height: 140px;
  padding: 24px;
}

.till-lines {
  min-height: 0;
  overflow: hidden;
}

.till-lines li {
  padding: 10px 8px;
}

.till-lines small {
  color: #6b746e;
  font-size: 12px;
  margin-left: 6px;
  white-space: nowrap;
}

.till-lines button {
  min-height: 34px;
}

.pos-pager {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto 1fr;
  min-height: 44px;
  padding-top: 10px;
}

.pos-pager:empty {
  min-height: 0;
  padding-top: 0;
}

.pos-pager button {
  min-height: 38px;
}

.pos-pager span {
  color: #536058;
  white-space: nowrap;
}

#cardMachineButtons {
  display: contents;
}

.payment-modal {
  text-align: center;
}

.payment-modal > div {
  display: grid;
  gap: 14px;
}

.payment-modal h2, .payment-modal p {
  margin: 0;
}

#paymentAmount {
  color: var(--brand-primary);
  font-size: 32px;
}

.payment-spinner {
  animation: spin 1s linear infinite;
  border: 6px solid #d7ddd5;
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  height: 58px;
  justify-self: center;
  width: 58px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 900px) {
  .topbar, .pos-header {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-grid, .form.inline {
    grid-template-columns: 1fr;
  }

  .product-grid-form {
    grid-template-columns: 1fr;
  }

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

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

  .choice-button {
    min-height: 32vh;
  }

  .pos-layout {
    grid-template-columns: minmax(260px, 38%) 1fr;
  }

  .token-row, .user-row, .card-machine-row, .sumup-pairing {
    grid-template-columns: 1fr;
  }

  .supplier-contact-row {
    grid-template-columns: 1fr;
  }

  .delivery-row {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 560px) {
  .table-row {
    grid-template-columns: 1fr;
  }

  .pos-page {
    padding: 8px;
  }

  .pos-brand-banner {
    font-size: 20px;
    height: 42px;
    margin-bottom: 6px;
  }

  .pos-step {
    height: calc(100dvh - 56px);
  }

  .pos-layout {
    gap: 8px;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(250px, 48%) minmax(0, 1fr);
  }

  .step-bar {
    min-height: 38px;
    margin-bottom: 6px;
  }

  .compact-bar h1 {
    font-size: 18px;
  }

  .till-side {
    gap: 6px;
    grid-template-rows: auto auto minmax(34px, 1fr) auto minmax(0, 0.8fr);
    padding: 8px;
  }

  .total-bar {
    gap: 6px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-top: 6px;
  }

  .total-bar strong {
    font-size: 20px;
  }

  .total-bar button {
    min-height: 38px;
  }

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

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

  .product {
    padding: 10px;
  }

  .product strong, .product span {
    font-size: 14px;
  }

  #stockTable .product-row {
    grid-template-columns: 1fr;
  }

  .bill-line-row {
    grid-template-columns: 1fr;
  }

  .transactions-row, .tab-item-row {
    grid-template-columns: 1fr;
  }

  .row-actions, .form-actions {
    flex-direction: column;
  }
}
