:root {
  --bg: #f0f0f0;
  --text: #212121;
  --primary-bg: #ffffff;
  --secondary-bg: #e8e8e8;
  --accent: #4aa8ff;
  --border: #ccc;
  --btn-bg: #4aa8ff;
  --btn-color: #fff;
  --error-bg: #ff6b6b;
  --success-bg: #53d769;
}
/* Dark mode overrides */
[data-theme="dark"] {
  --bg: #0f1420;
  --text: #e6ebff;
  --primary-bg: #161c2a;
  --secondary-bg: #1b2233;
  --accent: #7cc7ff;
  --border: #253150;
  --btn-bg: #4aa8ff;
  --btn-color: #02121f;
  --error-bg: #ff6b6b;
  --success-bg: #53d769;
}
* {
  box-sizing: border-box;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: 80px 1fr 420px;
  min-height: 100vh;
  gap: 20px;
  padding: 20px;
}
aside.sidebar, main.main, aside.cart {
  background: var(--primary-bg);
  border-radius: 18px;
  border: 1px solid var(--border);
}
.sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0;
  gap: 20px;
}
.logo {
  background: linear-gradient(135deg,var(--accent),#7cc7ff);
  color: #00122a;
  font-weight: 800;
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  user-select: none;
}
.nav-btn {
  width: 52px;
  height: 52px;
  background: var(--secondary-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: #8892a6;
  font-size: 20px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: .2s;
}
.nav-btn:hover,
.nav-btn.active {
  outline: 2px solid var(--border);
  color: var(--text);
}
.nav-bottom {
  margin-top: auto;
}
main.main {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
header.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
header .title h1 {
  margin: 0;
  font-weight: 800;
  letter-spacing: .2px;
  font-size: 1.6rem;
}
header .accent {
  color: var(--accent);
}
header .badge {
  background: var(--secondary-bg);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  margin-left: 6px;
  font-weight: 600;
}
header #dateStr {
  color: #8892a6;
  font-size: .9rem;
  margin-top: 4px;
}
.search {
  flex: 1;
  display: flex;
  justify-content: center;
  margin: 0 20px;
}
.input {
  background: var(--secondary-bg);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 10px;
  width: 100%;
  max-width: 480px;
  color: var(--text);
  font-size: 1rem;
}
.input:focus {
  outline-color: var(--accent);
}
.user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #243350;
  display: grid;
  place-items: center;
  font-weight: 700;
  user-select: none;
}
.who {
  color: var(--text);
}
.tabs {
  display: flex;
  gap: 10px;
  padding: 6px 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tab {
  background: var(--secondary-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: #8892a6;
  padding: 2px 2px;
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  transition: all 0.2s ease;
}
.tab.active {
  background: var(--primary-bg);
  color: var(--accent);
  border-color: var(--accent);
}
.tab:hover {
  transform: translateY(-2px);
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(180px,1fr));
  gap: 16px;
  overflow-y: auto;
  max-height: 520px;
}
.card {
  background: var(--secondary-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  position: relative;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,0,0,.35);
}
.img {
  height: 150px;
  background: var(--primary-bg);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.3s ease;
}
.card:hover .img img {
  transform: scale(1.05);
}
.body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.name {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 4px;
  line-height: 1.2;
}
.meta {
  font-size: 12px;
  color: #8892a6;
  margin-bottom: 8px;
}
.price {
  font-weight: 800;
  margin-top: 4px;
  font-size: 1.2rem;
  color: var(--accent);
}
.btn {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--secondary-bg);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  text-align: center;
  transition: all 0.2s ease;
}
.btn:hover {
  transform: translateY(-2px);
}
.btn.primary {
  background: var(--btn-bg);
  border-color: var(--btn-bg);
  color: var(--btn-color);
  font-weight: 700;
}
.btn.primary:hover {
  background: #3a97e6;
  border-color: #3a97e6;
}
/* Cart alignment improvements */

aside.cart {
  display: flex;
  flex-direction: column;
  padding: 18px;
  gap: 14px;
  max-height: 90%; /*90vh*/
}
.cart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cart-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 550px; /*350px*/
  padding-right: 6px;
}
.cart-item {
  display: grid;
  grid-template-columns: 60px 1fr 150px 50px 100px;
  /*grid-template-columns: 60px 1fr 160px 100px 40px;*/
  gap: 10px;
  align-items: center;
  background: var(--secondary-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  transition: all 0.2s ease;
}
.cart-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.cart-item img {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  object-fit: contain;
}
.cart-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text);
}
.cart-title h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}
.cart-title .each {
  color: #8892a6;
  font-size: 12px;
}
.qty-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-start;
}
.qty-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid #2a395e;
  background: #243454;
  color: #cfe4ff;
  cursor: pointer;
  font-weight: 700;
  font-size: 16px;
  display: grid;
  place-items: center;
  user-select: none;
  transition: all 0.2s ease;
}
.qty-btn:hover {
  background: #2c3e67;
}
.qty-input {
  width: 60px;
  text-align: center;
  padding: 4px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--primary-bg);
  color: var(--text);
}
.cart-price {
  text-align: right;
  font-weight: 700;
  color: var(--text);
  font-size: 1rem;
}
.cart-remove {
  display: flex;
  justify-content: center;
}
.cart-remove button {
  background: #3a1f1f;
  border: 1px solid #5b2b2b;
  color: #ffdcdc;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.cart-remove button:hover {
  background: #4d2929;
}
.cart-foot {
  display: grid;
  gap: 10px;
}
.totals {
  background: var(--primary-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
}
.totals > div {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: 1rem;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.totals input, .totals select {
  width: 100px;
  text-align: right;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--secondary-bg);
  color: var(--text);
}
.total-row.grand-total {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 8px;
  font-size: 1.1rem;
  font-weight: 700;
}
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert.success {
  background: var(--success-bg);
  color: #022b00;
}
.alert.error {
  background: var(--error-bg);
  color: #fff;
}
/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.modal-backdrop.show {
  display: flex;
}
.modal {
  background: var(--primary-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 95%;
  max-width: 480px;
  padding: 16px;
  color: var(--text);
}
.modal h3 {
  margin: 0 0 8px 0;
}
.modal .row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
  flex-wrap: wrap;
}
.modal .row .col {
  flex: 1 1 45%;
}
.modal input[type="text"],
.modal input[type="number"],
.modal select {
  width: 100%;
  background: var(--secondary-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px;
}
.modal .actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}
/* Scrollbar */
.cart-items::-webkit-scrollbar {
  width: 8px;
}
.cart-items::-webkit-scrollbar-thumb {
  background: var(--btn-bg);
  border-radius: 4px;
}
/* Responsive */
@media (max-width:1024px) {
  body {
    grid-template-columns: 1fr 420px;
  }
}
@media (max-width:768px) {
  body {
    grid-template-columns: 1fr;
  }
  main.main,
  aside.cart {
    max-height: none;
    height: auto;
    padding: 12px;
  }
  .grid {
    max-height: none;
  }
  .cart-item {
    grid-template-columns: 50px 1fr 140px 90px 36px;
  }
}
/* Dark/Light toggle button styles */
#modeToggle {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--accent);
  margin-left: 15px;
  padding: 6px;
  border-radius: 8px;
  transition: color 0.3s ease;
}
#modeToggle:hover {
  color: var(--btn-bg);
}
/* Stock indicator */
.stock-indicator {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
}
/* Focus styles for accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* Animation for cart updates */
@keyframes highlight {
  0% { background-color: var(--accent); }
  100% { background-color: var(--secondary-bg); }
}
.cart-item.highlight {
  animation: highlight 0.5s ease;
}
/* Receipt styles */
.receipt {
  width: 80mm;
  background: white;
  color: black;
  font-family: monospace;
  padding: 10px;
  font-size: 14px;
  line-height: 1.3;
}
.receipt-header {
  text-align: center;
  border-bottom: 1px dashed #000;
  padding-bottom: 10px;
  margin-bottom: 10px;
}
.receipt-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: bold;
}
.receipt-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}
.receipt-item-name {
  flex: 3;
}
.receipt-item-qty {
  flex: 1;
  text-align: center;
}
.receipt-item-price {
  flex: 2;
  text-align: right;
}
.receipt-totals {
  border-top: 1px dashed #000;
  margin-top: 10px;
  padding-top: 10px;
}
.receipt-total-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
}
.receipt-footer {
  text-align: center;
  margin-top: 15px;
  font-size: 12px;
}
/* Print receipt button */
#printReceiptBtn {
  margin-top: 10px;
}