:root {
  color-scheme: light;
  --bg: #f4f6f4;
  --panel: #ffffff;
  --panel-2: #f9fbfa;
  --ink: #17211d;
  --muted: #63706a;
  --faint: #eef2ef;
  --line: #d9e1dd;
  --line-dark: #becac4;
  --green: #0f6b45;
  --green-dark: #0a4f33;
  --blue: #235e9f;
  --amber: #a96313;
  --red: #a63f3f;
  --shadow: 0 14px 34px rgba(24, 43, 33, 0.08);
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.pos-shell {
  min-height: 100vh;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1540px;
  margin: 0 auto 14px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #10251c;
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  font-size: 13px;
  line-height: 1.2;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
}

.version-line,
.counter-status,
.panel-head p,
.label-text {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.counter-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(520px, 1fr) minmax(292px, 340px);
  gap: 14px;
  max-width: 1540px;
  margin: 0 auto;
  align-items: start;
}

.product-panel,
.ticket-panel,
.checkout-panel {
  min-height: calc(100vh - 98px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.product-panel,
.checkout-panel {
  position: sticky;
  top: 16px;
  overflow: hidden;
}

.ticket-panel {
  padding: 16px;
}

.product-panel,
.checkout-panel {
  padding: 14px;
}

.panel-head,
.ticket-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ticket-head {
  margin-bottom: 14px;
}

.ticket-head h2 {
  margin-top: 3px;
  font-size: 23px;
}

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

.icon-button,
.soft-button,
.danger-button,
.primary-button {
  min-height: 40px;
  border-radius: 7px;
  border: 1px solid var(--line-dark);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  padding: 0;
}

.icon-button svg,
.search-box svg,
.search-box button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.soft-button {
  padding: 0 13px;
}

.danger-button {
  border-color: #e3b7b7;
  color: var(--red);
  padding: 0 13px;
}

.primary-button {
  width: 100%;
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.primary-button:active {
  background: var(--green-dark);
}

.search-box {
  display: grid;
  grid-template-columns: 22px 1fr 34px;
  align-items: center;
  gap: 7px;
  min-height: 46px;
  margin-top: 14px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: #fff;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
}

.search-box button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.category-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 12px 0;
}

.category-tabs button,
.payment-grid button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: #293832;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.category-tabs button {
  padding: 0 6px;
  font-size: 12px;
}

.category-tabs button.active,
.payment-grid button.active {
  border-color: rgba(15, 107, 69, 0.35);
  background: #eaf5ef;
  color: var(--green-dark);
}

.product-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 246px);
  overflow-y: auto;
  padding-right: 2px;
}

.product-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: 100%;
  min-height: 94px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  text-align: left;
}

.product-row:hover {
  border-color: #aec8bc;
  background: #fbfdfc;
}

.product-main {
  min-width: 0;
}

.product-code,
.line-code {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
}

.product-name,
.line-name {
  margin-top: 4px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}

.product-meta,
.line-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.product-price {
  align-self: start;
  min-width: 74px;
  padding: 6px 8px;
  border-radius: 7px;
  background: #f0f5f9;
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
  text-align: right;
}

.bill-fields {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 10px;
  margin-bottom: 12px;
}

.bill-fields label,
.note-field,
.discount-row,
.received-field {
  display: grid;
  gap: 6px;
}

.bill-fields span,
.note-field span,
.discount-row span,
.received-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.bill-fields input,
.bill-fields select,
.note-field textarea,
.discount-row input,
.received-field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-dark);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 8px 10px;
}

.note-field textarea {
  min-height: 74px;
  resize: vertical;
}

.bill-fields input:focus,
.bill-fields select:focus,
.note-field textarea:focus,
.discount-row input:focus,
.received-field input:focus,
.line-table input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 107, 69, 0.12);
}

.line-table-shell {
  position: relative;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  background: #fff;
}

.line-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 660px;
}

.line-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 42px;
  background: #f7faf8;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
}

.line-table th,
.line-table td {
  padding: 9px 10px;
  vertical-align: middle;
}

.line-table tbody tr + tr {
  border-top: 1px solid var(--faint);
}

.line-table th:nth-child(2),
.line-table th:nth-child(3),
.line-table th:nth-child(4),
.line-table th:nth-child(5),
.line-table td:nth-child(2),
.line-table td:nth-child(3),
.line-table td:nth-child(4),
.line-table td:nth-child(5) {
  text-align: right;
}

.qty-control {
  display: inline-grid;
  grid-template-columns: 30px 48px 30px;
  align-items: center;
  gap: 4px;
}

.qty-control button,
.remove-line {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--ink);
  font-weight: 900;
}

.qty-control button {
  width: 30px;
  height: 30px;
  font-size: 17px;
}

.qty-control input,
.money-input {
  width: 72px;
  height: 34px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  color: var(--ink);
  text-align: right;
  padding: 5px 7px;
}

.qty-control input {
  width: 48px;
}

.line-total {
  min-width: 84px;
  font-weight: 900;
  white-space: nowrap;
}

.remove-line {
  width: 32px;
  height: 32px;
  color: var(--red);
}

.empty-ticket {
  position: absolute;
  inset: 56px 16px 16px;
  display: grid;
  place-content: center;
  gap: 6px;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.empty-ticket strong {
  color: var(--ink);
  font-size: 19px;
}

.empty-ticket.hidden {
  display: none;
}

.note-field {
  margin-top: 12px;
}

.totals {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.totals > div,
.discount-row,
.change-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  border-bottom: 1px solid var(--faint);
}

.totals span,
.change-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.totals strong,
.change-row strong {
  font-size: 18px;
}

.discount-row input,
.received-field input {
  max-width: 132px;
  text-align: right;
}

.grand-total {
  min-height: 58px;
  border-bottom: 0;
}

.grand-total strong {
  color: var(--green-dark);
  font-size: 30px;
  line-height: 1;
}

.payment-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.payment-grid button {
  min-height: 42px;
}

.received-field {
  margin-top: 14px;
}

.change-row {
  margin-top: 8px;
  border-bottom: 0;
}

.paid-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--line-dark);
}

.paid-dot.ready {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(15, 107, 69, 0.12);
}

.action-stack {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.recent-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--faint);
}

.recent-list {
  display: grid;
  gap: 7px;
  margin-top: 9px;
}

.recent-item {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: inherit;
  text-align: left;
}

.recent-item strong {
  font-size: 13px;
}

.recent-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 10;
  transform: translate(-50%, 14px);
  max-width: min(520px, calc(100vw - 28px));
  padding: 11px 14px;
  border: 1px solid rgba(15, 107, 69, 0.25);
  border-radius: 8px;
  background: #10251c;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.print-receipt {
  display: none;
}

@media (max-width: 1400px) {
  .workspace {
    grid-template-columns: 330px minmax(0, 1fr);
  }

  .checkout-panel {
    position: static;
    grid-column: 1 / -1;
    min-height: auto;
  }
}

@media (max-width: 820px) {
  .pos-shell {
    padding: 10px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    display: flex;
    flex-direction: column;
  }

  .product-panel,
  .ticket-panel,
  .checkout-panel {
    position: static;
    width: 100%;
    min-height: auto;
  }

  .product-list {
    max-height: 420px;
  }

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

  .line-table-shell {
    min-height: 300px;
    overflow: visible;
  }

  .line-table {
    min-width: 0;
  }

  .line-table thead {
    display: none;
  }

  .line-table,
  .line-table tbody,
  .line-table tr,
  .line-table td {
    display: block;
    width: 100%;
  }

  .line-table tbody tr {
    display: grid;
    gap: 9px;
    padding: 12px;
  }

  .line-table th,
  .line-table td {
    padding: 0;
  }

  .line-table td:nth-child(2),
  .line-table td:nth-child(3),
  .line-table td:nth-child(4),
  .line-table td:nth-child(5),
  .line-table td:nth-child(6) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
  }

  .line-table td:nth-child(2)::before {
    content: "Qty";
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
  }

  .line-table td:nth-child(3)::before {
    content: "Price";
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
  }

  .line-table td:nth-child(4)::before {
    content: "Disc.";
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
  }

  .line-table td:nth-child(5)::before {
    content: "Total";
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
  }
}

@media print {
  body {
    background: #fff;
  }

  .pos-shell {
    display: none;
  }

  .print-receipt {
    display: block;
    padding: 24px;
    color: #111;
    font-family: Arial, Helvetica, sans-serif;
  }

  .print-receipt h1 {
    font-size: 22px;
    margin: 0 0 4px;
  }

  .print-receipt .receipt-meta {
    margin-bottom: 16px;
    color: #333;
    font-size: 12px;
  }

  .print-receipt table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
  }

  .print-receipt th,
  .print-receipt td {
    padding: 7px 0;
    border-bottom: 1px solid #ddd;
    text-align: left;
  }

  .print-receipt th:nth-child(2),
  .print-receipt th:nth-child(3),
  .print-receipt td:nth-child(2),
  .print-receipt td:nth-child(3) {
    text-align: right;
  }

  .print-receipt .receipt-total {
    margin-top: 14px;
    text-align: right;
    font-size: 18px;
    font-weight: 900;
  }
}
