:root {
  --black: #0B0B0C;
  --accent: #FF4500;
  --accent-dim: #ffe4d6;
  --white: #FFFFFF;
  --gray-50: #FAFAFA;
  --gray-100: #F2F2F2;
  --gray-300: #D9D9D9;
  --gray-500: #8A8A8E;
  --gray-700: #3A3A3C;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--gray-50);
  color: var(--black);
}

/* ── Top bar ───────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--black);
  color: var(--white);
  padding: 14px 24px;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  background: var(--accent);
  color: var(--white);
  font-weight: bold;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 14px;
}

.brand-name { font-size: 18px; font-weight: bold; letter-spacing: 0.2px; }
.accent { color: var(--accent); }

.location-picker { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.location-picker label { color: var(--gray-300); }
.location-picker select {
  background: var(--gray-700);
  color: var(--white);
  border: 1px solid #555;
  border-radius: var(--radius);
  padding: 6px 10px;
}

/* ── Tabs ──────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-300);
  padding: 0 20px;
}

.tab {
  border: none;
  background: none;
  padding: 14px 16px;
  font-size: 14px;
  font-family: Arial, sans-serif;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}

.tab.active {
  color: var(--black);
  border-bottom-color: var(--accent);
  font-weight: bold;
}

.tab.disabled {
  color: var(--gray-300);
  cursor: not-allowed;
}

/* ── Main layout ───────────────────────── */
main { padding: 24px; max-width: 1200px; margin: 0 auto; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-header h1 { font-size: 22px; margin: 0; }

/* ── Buttons ───────────────────────────── */
.btn {
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  font-family: Arial, sans-serif;
}

.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover { background: #e03e00; }

.btn-ghost { background: transparent; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-ghost:hover { background: var(--gray-100); }

.btn-icon {
  background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gray-500);
  line-height: 1;
}

/* ── Filters ───────────────────────────── */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filters input, .filters select {
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: Arial, sans-serif;
}

#searchInput { flex: 1; min-width: 220px; }

/* ── Banner ────────────────────────────── */
.banner {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
.hidden { display: none !important; }

/* ── Table ─────────────────────────────── */
.table-wrap {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  background: var(--gray-100);
  padding: 10px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-300);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
}

tr:last-child td { border-bottom: none; }

.empty-state { text-align: center; color: var(--gray-500); padding: 30px !important; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: bold;
  text-transform: capitalize;
}

.badge-in_stock { background: #e3f6e8; color: #1e7a3e; }
.badge-sold { background: var(--gray-100); color: var(--gray-700); }
.badge-reserved { background: #fff4d9; color: #8a6a00; }
.badge-in_repair { background: var(--accent-dim); color: var(--accent); }
.badge-transferred { background: #e6eefc; color: #2952a3; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
}

/* ── Modal ─────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11,11,12,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 460px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px 24px 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.modal-header h2 { font-size: 18px; margin: 0; }

.item-type-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  background: var(--gray-100);
  padding: 4px;
  border-radius: var(--radius);
}

.type-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
  color: var(--gray-700);
  font-family: Arial, sans-serif;
}

.type-btn.active { background: var(--black); color: var(--white); }

.form-row { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.form-row label { font-size: 12px; font-weight: bold; color: var(--gray-700); }
.form-row input, .form-row select, .form-row textarea {
  padding: 9px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: Arial, sans-serif;
}

.form-row.two-col { flex-direction: row; gap: 12px; }
.form-row.two-col > div { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.form-row.two-col label { font-size: 12px; font-weight: bold; color: var(--gray-700); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ── Toast ─────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--black);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 200;
}
.toast.error { background: #c0392b; }

/* ── Product search & quick add ───────────── */
.search-results {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  margin-bottom: 6px;
}

.search-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
}
.search-result-row:last-child { border-bottom: none; }

.sr-name { font-weight: bold; font-size: 13px; }
.sr-meta { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.hint { font-size: 12px; color: var(--gray-500); }

.product-info-card {
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.badge-out_of_stock { background: #fbe0e0; color: #a12b2b; }

/* ── Home screen grid ──────────────────────── */
.home-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  max-width: 900px;
  margin: 20px auto;
}

.home-box {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 10px;
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-family: Arial, sans-serif;
  font-size: 14px;
  font-weight: bold;
  color: var(--black);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.home-box:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  border-color: var(--accent);
}

.home-box:disabled {
  color: var(--gray-300);
  cursor: not-allowed;
  background: var(--gray-50);
}

.home-icon { font-size: 30px; }

.panel-header-left { display: flex; align-items: center; gap: 10px; }
.back-btn { font-size: 20px; }

.location-locked {
  background: var(--gray-700);
  color: var(--white);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: bold;
}

.input-with-button { display: flex; gap: 8px; }
.input-with-button input { flex: 1; }

/* ── Checkout ──────────────────────────────── */
.checkout-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

.customer-bar {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.customer-bar .form-row { margin-bottom: 0; flex: 1; max-width: 280px; }
.customer-bar #customerLookupNote { flex: 1; text-align: right; }

.side-card {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.side-card h3 { margin: 0 0 10px; font-size: 14px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 6px 0;
  cursor: pointer;
}

.totals-card { font-size: 14px; }
.totals-row { display: flex; justify-content: space-between; padding: 4px 0; }
.totals-final { font-weight: bold; font-size: 17px; border-top: 1px solid var(--gray-300); margin-top: 6px; padding-top: 10px; }

.btn-full { width: 100%; padding: 14px; font-size: 15px; }

.cart-qty-input { width: 55px; padding: 4px 6px; border: 1px solid var(--gray-300); border-radius: 4px; }

.payment-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.payment-grid .type-btn { padding: 10px 4px; }

.cart-price-input { width: 75px; padding: 4px 6px; border: 1px solid var(--gray-300); border-radius: 4px; }

@media (max-width: 900px) {
  .checkout-layout { grid-template-columns: 1fr; }
}

/* ── Receipt ───────────────────────────────── */
.receipt-modal { width: 340px; }
.receipt {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: #000;
}
.receipt .r-center { text-align: center; }
.receipt hr { border: none; border-top: 1px dashed #999; margin: 8px 0; }
.receipt .r-line { display: flex; justify-content: space-between; }
.receipt .r-total { font-weight: bold; font-size: 15px; }
.receipt .r-policy { font-size: 11px; color: #444; text-align: center; }

/* ── Printable label ───────────────────────── */
.label-modal { width: 300px; }
.label-print {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 340px;
  overflow-y: auto;
}
.label-copy {
  border: 1px dashed var(--gray-300);
  padding: 14px;
  text-align: center;
  font-family: Arial, sans-serif;
}
.label-copy .l-name { font-size: 13px; font-weight: bold; margin-bottom: 6px; }
.label-copy .l-price { font-size: 18px; font-weight: bold; color: var(--black); margin-top: 6px; }
.label-copy .l-code { font-size: 11px; color: var(--gray-500); margin-top: 4px; }
.label-copy img { width: 110px; height: 110px; }

@media print {
  body.printing-label * { visibility: hidden; }
  body.printing-label .label-print, body.printing-label .label-print * { visibility: visible; }
  body.printing-label .label-print {
    position: absolute; top: 0; left: 0; max-height: none; overflow: visible;
  }
  body.printing-label .label-copy { page-break-after: always; }
}

@media print {
  body * { visibility: hidden; }
  .receipt, .receipt * { visibility: visible; }
  .receipt { position: absolute; top: 0; left: 0; width: 100%; }
  .modal-overlay { background: none; }
  .modal-footer { display: none; }
}

.history-customer-card {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
}
.history-sale-card {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.history-sale-header { display: flex; justify-content: space-between; font-weight: bold; margin-bottom: 6px; }
.history-line { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; color: var(--gray-700); }

.repair-part-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 13px; border-bottom: 1px solid var(--gray-100); }

.company-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; font-size: 13px; border-bottom: 1px solid var(--gray-100); }

.task-notes-log {
  max-height: 140px;
  overflow-y: auto;
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 12px;
}
.task-note-entry { padding: 4px 0; border-bottom: 1px solid var(--gray-300); }
.task-note-entry:last-child { border-bottom: none; }
.task-note-time { color: var(--gray-500); font-weight: bold; margin-right: 6px; }

.readonly-banner {
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 14px;
}

/* ── Pattern lock grid ─────────────────────── */
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  width: 180px;
  margin: 8px auto;
  padding: 14px;
  background: var(--gray-100);
  border-radius: var(--radius);
}
.pattern-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--gray-500);
  background: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  color: var(--gray-500);
  user-select: none;
}
.pattern-dot.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}
.pattern-controls { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }

@media (max-width: 700px) {
  .home-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  main { padding: 14px; }
  .form-row.two-col { flex-direction: column; }
}
