:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --line: #d8dde6;
  --text: #111827;
  --muted: #5f6b7d;
  --primary: #1663d6;
  --primary-strong: #0f4fb0;
  --soft: #eef2f7;
  --danger: #b42318;
  --success-bg: #d9f6e4;
  --success-text: #066c3f;
  font-family: "SF Pro Display", "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f8f9fb 0%, var(--bg) 100%);
  color: var(--text);
}

.pos-layout {
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 14px;
  padding: 14px;
}

.workspace-panel,
.cart-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.workspace-panel {
  overflow: hidden;
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.workspace-header h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.workspace-header p {
  margin: 4px 0 0;
}

.workspace-view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

.hidden {
  display: none;
}

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

.product-tile {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f9fbff;
  overflow: hidden;
  text-align: left;
  padding: 0;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.product-tile:hover {
  cursor: pointer;
  transform: translateY(-2px);
  border-color: #b7c7e5;
  box-shadow: 0 8px 22px rgba(33, 64, 123, 0.12);
}

.product-image {
  height: 130px;
  width: 100%;
  object-fit: cover;
  background: linear-gradient(125deg, #dce8f8 0%, #edf2fb 100%);
  display: block;
}

.product-content {
  padding: 12px;
}

.product-name {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
}

.product-price {
  margin: 8px 0 0;
  color: #344056;
  font-weight: 600;
}

.tip-card,
.success-card {
  max-width: 560px;
  margin: 0 auto;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}

.tip-card h2,
.success-card h2 {
  margin: 0 0 10px;
  font-size: 34px;
  letter-spacing: -0.02em;
}

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

.tip-grid button {
  font-size: 22px;
  font-weight: 600;
  padding: 22px 14px;
  border-radius: 12px;
}

.custom-tip-row {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.custom-tip-row input {
  flex: 1;
}

.cart-panel {
  padding: 14px;
  gap: 8px;
}

.cart-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.cart-header h2 {
  margin: 4px 0;
  font-size: 32px;
  letter-spacing: -0.02em;
}

.reader-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.customer-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding-top: 8px;
}

label {
  color: var(--muted);
  font-size: 13px;
}

input,
button {
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 16px;
}

input {
  width: 100%;
  padding: 10px 11px;
  background: #fff;
}

button {
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
}

button:hover {
  cursor: pointer;
}

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

button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

button.primary:hover {
  background: var(--primary-strong);
}

button.ghost {
  background: var(--soft);
}

.cart-items {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  flex: 1;
  min-height: 140px;
  overflow: auto;
}

.cart-empty {
  color: var(--muted);
  padding: 12px 2px;
}

.cart-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #edf0f5;
}

.cart-item-thumb {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  background: #eaf0fb;
}

.cart-item-name {
  margin: 0;
  font-size: 15px;
}

.cart-item-price {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.qty-controls {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.qty-controls button {
  border: 0;
  border-radius: 0;
  min-width: 30px;
  padding: 6px 8px;
  background: #fff;
}

.qty-controls span {
  min-width: 30px;
  text-align: center;
  font-weight: 600;
  line-height: 32px;
}

.cart-footer {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: grid;
  gap: 8px;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #313f56;
}

.grand-total {
  font-size: 22px;
}

.muted {
  color: var(--muted);
  margin: 0;
}

#paymentStatus.error,
#tipStatus.error {
  color: var(--danger);
}

#paymentStatus.success,
#tipStatus.success {
  color: var(--success-text);
}

.success-card {
  background: var(--success-bg);
  border-color: #abdfbf;
  color: var(--success-text);
}

#successAmount {
  font-size: 44px;
  margin: 0 0 8px;
  font-weight: 700;
}

@media (max-width: 1100px) {
  .pos-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .workspace-view {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .products-grid {
    grid-template-columns: 1fr;
  }

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

  .workspace-header h1 {
    font-size: 24px;
  }

  .cart-header h2 {
    font-size: 26px;
  }
}
