* {
  box-sizing: border-box;
}

:root {
  --bg: #f6f2e9;
  --panel: #fffdf8;
  --text: #1f2a22;
  --muted: #6f746d;
  --green-900: #163a29;
  --green-800: #1f5c3f;
  --green-700: #2b7a54;
  --green-100: #e7f2eb;
  --gold-500: #c79a3d;
  --gold-100: #f4ead2;
  --danger: #9f3131;
  --shadow: 0 12px 28px rgba(22, 58, 41, 0.10);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

html,
body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, #faf7f0 0%, #f4efe5 100%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  min-height: 100%;
}

body {
  padding: 14px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  max-width: 1024px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, var(--green-900), var(--green-800));
  color: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255,255,255,0.92);
  padding: 6px;
  object-fit: contain;
}

.brand-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.brand-subtitle {
  opacity: 0.85;
  font-size: 0.9rem;
}

.layout {
  display: grid;
  gap: 14px;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px;
}

.summary-grid,
.product-grid,
.settings-grid,
.action-grid,
.inventory-grid {
  display: grid;
  gap: 12px;
}

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

.summary-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbf8 100%);
  border: 1px solid #edf2ed;
  border-radius: var(--radius-md);
  padding: 14px;
}

.summary-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.summary-value {
  font-size: 1.35rem;
  font-weight: 700;
}

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

.section-header h2 {
  margin: 0;
  font-size: 1.12rem;
}

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

.product-btn {
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfaf7 100%);
  color: var(--text);
  padding: 16px 14px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  text-align: left;
  box-shadow: inset 0 0 0 1px #ece7db;
}

.product-btn:active {
  transform: scale(0.99);
}

.product-name {
  font-weight: 700;
}

.product-price {
  color: var(--green-800);
  font-size: 1.1rem;
  font-weight: 700;
}

.product-stock {
  color: var(--muted);
  font-size: 0.82rem;
}

.bundle-btn {
  background: linear-gradient(180deg, var(--gold-100) 0%, #fff7e9 100%);
}

.case-btn,
.mix-btn {
  background: linear-gradient(180deg, var(--green-100) 0%, #f6fbf8 100%);
}

.custom-btn {
  background: linear-gradient(180deg, #f1f1f1 0%, #fafafa 100%);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span {
  font-size: 0.9rem;
  color: var(--muted);
}

.field input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid #d8dfd8;
  background: #fff;
  padding: 13px 14px;
  min-height: 48px;
}

.toggle-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.toggle-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #faf9f5;
  border-radius: 14px;
  padding: 12px 14px;
  border: 1px solid #ece7db;
}

.note-box {
  margin-top: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--muted);
  background: #faf9f5;
  border-left: 4px solid var(--gold-500);
  border-radius: 12px;
  padding: 12px;
}

.cart-items,
.recent-sales {
  display: grid;
  gap: 10px;
}

.empty-state {
  color: var(--muted);
}

.cart-row,
.sale-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: #faf9f5;
  border: 1px solid #ece7db;
  border-radius: 14px;
  padding: 12px;
}

.cart-row-left {
  min-width: 0;
}

.cart-row-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.cart-row-meta,
.sale-row-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.cart-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.qty-btn,
.ghost-btn,
.primary-btn,
.secondary-btn,
.small-btn {
  border-radius: 14px;
  border: 0;
  padding: 12px 14px;
  min-height: 46px;
}

.qty-btn,
.ghost-btn,
.secondary-btn {
  background: #f0eee8;
  color: var(--text);
}

.primary-btn {
  background: linear-gradient(135deg, var(--green-800), var(--green-700));
  color: #fff;
  font-weight: 700;
}

.secondary-btn {
  font-weight: 700;
}

.small-btn {
  min-height: 38px;
  padding: 9px 12px;
}

.totals-card {
  margin-top: 12px;
  background: #faf9f5;
  border: 1px solid #ece7db;
  border-radius: 16px;
  padding: 12px;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}

.grand-total {
  font-size: 1.08rem;
  font-weight: 700;
  border-top: 1px solid #e9e2d4;
  margin-top: 6px;
  padding-top: 12px;
}

.action-grid {
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
}

.status-box {
  margin-top: 12px;
  background: #f3f6f3;
  color: var(--green-900);
  border-radius: 14px;
  padding: 12px;
  border: 1px solid #dfe9e1;
  font-weight: 700;
}

.sale-row {
  flex-direction: column;
}

.sale-row-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.sale-amount {
  font-weight: 700;
}

.sale-method {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--green-100);
  color: var(--green-900);
}

.sale-method.cash {
  background: var(--gold-100);
  color: #6a4b13;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 23, 18, 0.45);
}

.modal-card {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 40px auto;
  background: var(--panel);
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 20px 44px rgba(16, 23, 18, 0.22);
}

.inventory-grid {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 12px;
}

@media (min-width: 900px) {
  .layout {
    grid-template-columns: 1.05fr 0.95fr;
    align-items: start;
  }

  .summary-panel,
  .controls-panel,
  .settings-panel {
    grid-column: 1 / 2;
  }

  .cart-panel,
  .tracker-panel {
    grid-column: 2 / 3;
  }

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

@media (max-width: 640px) {
  body {
    padding: 10px;
  }

  .topbar {
    padding: 14px;
    flex-direction: column;
    align-items: stretch;
  }

  .summary-grid,
  .product-grid,
  .inventory-grid,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .cart-row,
  .sale-row-top {
    flex-direction: column;
  }
}
