* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #f4f5f7;
  color: #1f2430;
}
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px;
  background: #1f2430;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  flex-shrink: 0;
}
.sidebar .brand {
  font-size: 22px;
  font-weight: 700;
  padding: 8px 24px 24px;
  letter-spacing: 1px;
}
.sidebar a {
  color: #c6c9d1;
  text-decoration: none;
  padding: 12px 24px;
  font-size: 15px;
}
.sidebar a:hover { background: #2b3142; color: #fff; }
.sidebar a.active { background: #3457d5; color: #fff; font-weight: 600; }
.content { flex: 1; padding: 28px 32px; max-width: 1200px; }
h1 { margin-top: 0; font-size: 24px; }
h2 { font-size: 18px; }

.card-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.card {
  background: #fff;
  border-radius: 10px;
  padding: 18px 22px;
  min-width: 180px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.card .label { font-size: 13px; color: #6b7280; margin-bottom: 6px; }
.card .value { font-size: 26px; font-weight: 700; }
.card.warn .value { color: #b45309; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eef0f3; font-size: 14px; }
th { background: #fafbfc; font-weight: 600; color: #4b5563; }
tr:hover td { background: #fafcff; }

button, .btn {
  background: #3457d5;
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
button:hover { background: #2a46b3; }
button.secondary { background: #e5e7eb; color: #1f2430; }
button.secondary:hover { background: #d1d5db; }
button.danger { background: #dc2626; }
button.danger:hover { background: #b91c1c; }
button:disabled { background: #c6c9d1; cursor: not-allowed; }

input, select, textarea {
  padding: 8px 10px;
  border: 1px solid #d5d8dd;
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
}
label { font-size: 13px; color: #4b5563; margin-bottom: 4px; display: block; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; }
.row > .field { flex: 1; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
.toolbar input[type=text] { max-width: 280px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: none; align-items: center; justify-content: center; z-index: 50;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 10px; padding: 24px; width: 420px; max-width: 90vw;
  max-height: 85vh; overflow-y: auto;
}
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.pos-layout { display: flex; gap: 24px; align-items: flex-start; }
.pos-search { flex: 1.3; }
.pos-cart { flex: 1; background: #fff; border-radius: 10px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 14px; }
.product-tile {
  background: #fff; border-radius: 8px; padding: 12px; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08); border: 1px solid transparent;
}
.product-tile:hover { border-color: #3457d5; }
.product-tile .name { font-weight: 600; font-size: 14px; }
.product-tile .meta { font-size: 12px; color: #6b7280; margin-top: 4px; }
.product-tile .price { font-size: 15px; font-weight: 700; margin-top: 6px; color: #3457d5; }
.product-tile.out-of-stock { opacity: 0.5; cursor: not-allowed; }
.product-tile .thumb { width: 100%; height: 90px; object-fit: cover; border-radius: 6px; background: #f4f5f7; margin-bottom: 8px; }
.product-tile .thumb-placeholder {
  width: 100%; height: 90px; border-radius: 6px; background: #f4f5f7; margin-bottom: 8px;
  display: flex; align-items: center; justify-content: center; color: #c6c9d1; font-size: 24px;
}
.row-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; background: #f4f5f7; display: block; }
.row-thumb-placeholder {
  width: 36px; height: 36px; border-radius: 6px; background: #f4f5f7;
  display: flex; align-items: center; justify-content: center; color: #c6c9d1; font-size: 14px;
}

.cart-item { padding: 8px 0; border-bottom: 1px solid #eef0f3; }
.cart-item-top { display: flex; justify-content: space-between; align-items: center; }
.cart-item .qty-controls { display: flex; align-items: center; gap: 6px; }
.cart-item .qty-controls button { padding: 2px 8px; font-size: 14px; }
.cart-item-discount { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.cart-item-discount select { width: 70px; padding: 4px 6px; font-size: 12px; }
.cart-item-discount input { width: 70px; padding: 4px 6px; font-size: 12px; }
.cart-item-discount .line-net { font-size: 12px; color: #6b7280; margin-left: auto; }
.cart-summary-lines { margin-top: 12px; font-size: 14px; color: #4b5563; }
.cart-summary-lines .line { display: flex; justify-content: space-between; padding: 3px 0; }
.cart-total { display: flex; justify-content: space-between; font-size: 18px; font-weight: 700; margin-top: 14px; padding-top: 14px; border-top: 2px solid #1f2430; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.badge.low { background: #fef3c7; color: #92400e; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.out { background: #fee2e2; color: #991b1b; }
.badge.count { background: #3457d5; color: #fff; }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: #1f2430; color: #fff;
  padding: 12px 18px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s; z-index: 100;
}
.toast.show { opacity: 1; }
.toast.error { background: #dc2626; }

.receipt { font-family: 'Courier New', monospace; font-size: 13px; }
.receipt hr { border: none; border-top: 1px dashed #999; }
.receipt .line { display: flex; justify-content: space-between; }

@media print {
  .sidebar, .no-print { display: none !important; }
  .content { padding: 0; }
}
