:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f8fafc;
  --card: #fff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #059669;
  --danger: #dc2626;
  --radius: 8px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }

.app { max-width: 1200px; margin: 0 auto; padding: 16px; }

.nav-tabs {
  display: flex; gap: 4px; margin-bottom: 20px; background: var(--card);
  padding: 6px; border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.tab {
  flex: 1; padding: 10px 16px; border: none; background: transparent; cursor: pointer;
  font-size: 0.95rem; border-radius: 6px; color: var(--text-muted); transition: all 0.2s;
}
.tab:hover { background: #f1f5f9; color: var(--text); }
.tab.active { background: var(--primary); color: #fff; }

.view { display: none; }
.view.active { display: block; }

/* POS */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 24px; }
@media (max-width: 900px) { .pos-layout { grid-template-columns: 1fr; } }

.pos-left { display: flex; flex-direction: column; gap: 16px; }
.scanner-box {
  background: var(--card); padding: 20px; border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
#barcode-reader { min-height: 200px; margin-bottom: 12px; border-radius: var(--radius); overflow: hidden; }
#barcode-reader:empty { display: none; }
.hint { font-size: 0.85rem; color: var(--text-muted); margin: 8px 0 4px; }
.manual-scan { display: flex; gap: 8px; }
.manual-scan input { flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.product-search { position: relative; }
.product-search input { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.search-results {
  position: absolute; top: 100%; left: 0; right: 0; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  max-height: 200px; overflow-y: auto; z-index: 10; margin-top: 4px; box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.search-results:empty { display: none; }
.search-results .item {
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.search-results .item:hover { background: #f8fafc; }
.search-results .item:last-child { border-bottom: none; }

.pos-right {
  background: var(--card); border-radius: var(--radius); padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); display: flex; flex-direction: column;
}
.cart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.cart-header h2 { margin: 0; font-size: 1.25rem; }
.cart-list { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; max-height: 300px; }
.cart-list li {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 0;
  border-bottom: 1px solid var(--border); gap: 8px;
}
.cart-list .qty-controls { display: flex; align-items: center; gap: 4px; }
.cart-list .qty-btn { width: 28px; height: 28px; padding: 0; font-size: 1rem; line-height: 1; }
.cart-list .remove-btn { color: var(--danger); background: none; border: none; cursor: pointer; padding: 4px; }
.cart-footer { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 12px; }
.totals .row { display: flex; justify-content: space-between; margin-bottom: 4px; }
.totals .total { font-size: 1.2rem; font-weight: 700; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.payment-section { margin: 12px 0; }
.payment-section label { display: block; font-size: 0.9rem; margin-bottom: 4px; }
.payment-section select { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.checkout-actions { display: flex; gap: 8px; margin-top: 12px; }
.checkout-actions .btn { flex: 1; }

/* Buttons */
.btn { padding: 10px 18px; border: none; border-radius: var(--radius); cursor: pointer; font-size: 0.95rem; font-weight: 500; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }

/* Tables */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-header h2 { margin: 0; }
.table-wrap { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { background: #f8fafc; font-weight: 600; font-size: 0.85rem; color: var(--text-muted); }
.data-table tbody tr:hover { background: #f8fafc; }
.product-filters { margin-bottom: 12px; }
.product-filters input { padding: 10px; width: 100%; max-width: 300px; border: 1px solid var(--border); border-radius: var(--radius); }

/* Dashboard */
.dashboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.stat-card {
  background: var(--card); padding: 24px; border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.stat-card h3 { margin: 0 0 8px; font-size: 0.95rem; color: var(--text-muted); }
.stat-value { font-size: 1.75rem; font-weight: 700; margin: 0; color: var(--primary); }
.stat-label { font-size: 0.85rem; color: var(--text-muted); margin: 4px 0 0; }

/* Modal */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; align-items: center; justify-content: center; padding: 20px; }
.modal.show { display: flex; }
.modal-content { background: var(--card); border-radius: var(--radius); padding: 24px; max-width: 440px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { margin: 0; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); padding: 0 4px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.9rem; margin-bottom: 4px; font-weight: 500; }
.form-group input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); }

/* Receipt */
.receipt-content { max-width: 360px; }
.receipt-body { font-family: monospace; font-size: 0.9rem; white-space: pre-wrap; margin-bottom: 16px; }
.receipt-actions { display: flex; justify-content: flex-end; }

/* Actions in tables */
.action-btn { padding: 6px 12px; font-size: 0.85rem; margin-right: 4px; }
.action-btn.edit { background: #e0f2fe; color: #0284c7; }
.action-btn.delete { background: #fee2e2; color: var(--danger); }
