:root {
  /* Tanzanite POS's own identity - distinct from both Pamoja's teal
     (see tanzanite_pamoja_web/style.css's own :root comment) and any
     one client's storefront brand (Gina's gold lives in
     tanzanite_storefront's theme_content, not here) - staff should be
     able to tell "I'm in the till app" apart from "I'm on the shop
     site" at a glance. Steel blue reads as calm/functional, not
     tied to any retail vertical. */
  --pos-primary: #2c5f8a;
  --pos-primary-dark: #1f4463;
  --pos-primary-light: #e8f0f6;
  --pos-ink: #1a1f1e;
  --pos-muted: #6b7674;
  --pos-border: #e1e6e5;
  --pos-input-border: #b7c1bf;
  --pos-bg: #f5f7f8;
  --pos-white: #ffffff;
  --pos-danger: #b3261e;
  --pos-success: #1c7a34;
  --pos-warning: #9a6400;
  --pos-radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--pos-bg);
  color: var(--pos-ink);
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--pos-muted); font-weight: normal; }

/* Header */
.pos-header {
  background: var(--pos-primary);
  color: var(--pos-white);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.pos-header-brand { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.pos-header-logo { width: 26px; height: 26px; border-radius: 6px; object-fit: cover; display: block; }
.pos-header-actions { display: flex; align-items: center; gap: 10px; }
.pos-header-user { font-size: 0.82rem; opacity: 0.9; }
.pos-header-btn {
  background: rgba(255, 255, 255, 0.14);
  color: var(--pos-white);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.pos-header-btn:hover { background: rgba(255, 255, 255, 0.24); }

.pos-main { padding: 14px; max-width: 1200px; margin: 0 auto; }

/* State blocks */
.pos-state { text-align: center; padding: 50px 0; color: var(--pos-muted); }
.pos-state--empty { padding: 30px 16px; }
.pos-error-banner {
  background: #f4e4e2;
  color: var(--pos-danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 10px;
}

/* Login screen (mirrors tanzanite_pamoja_web's app-login-card shape) */
.pos-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--pos-primary-light) 0%, var(--pos-bg) 260px);
}
.pos-login-card {
  width: 100%;
  max-width: 360px;
  background: var(--pos-white);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius);
  padding: 32px 28px 28px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(31, 68, 99, 0.12);
}
.pos-login-logo { display: block; margin: 0 auto 14px; border-radius: 10px; }
.pos-login-title { margin: 0 0 4px; font-size: 1.5rem; color: var(--pos-primary-dark); }
.pos-login-sub { margin: 0 0 20px; color: var(--pos-muted); }
.pos-login-astranite {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  text-decoration: none;
  color: var(--pos-muted);
  font-size: 0.85rem;
  opacity: 0.92;
}
.pos-login-astranite img { display: block; border-radius: 3px; }

/* Forms */
.pos-form { display: flex; flex-direction: column; gap: 14px; text-align: left; margin-top: 4px; }
.pos-form label { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; font-weight: 600; }
.pos-form input, .pos-form select, .pos-form textarea {
  font: inherit;
  color: var(--pos-ink);
  padding: 10px 12px;
  border: 1.5px solid var(--pos-input-border);
  border-radius: 7px;
  background: var(--pos-white);
}
.pos-form input:focus, .pos-form select:focus {
  outline: none;
  border-color: var(--pos-primary);
  box-shadow: 0 0 0 3px rgba(44, 95, 138, 0.15);
}
.pos-hint { color: var(--pos-muted); font-size: 0.78rem; margin: 2px 0 0; font-weight: normal; }

.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px; /* touch target */
}
.btn-primary { background: var(--pos-primary); color: var(--pos-white); }
.btn-primary:hover { background: var(--pos-primary-dark); }
.btn-secondary { background: var(--pos-primary-light); color: var(--pos-primary-dark); }
.btn-danger { background: #f4e4e2; color: var(--pos-danger); }
.btn-block { width: 100%; text-align: center; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Register / checkout screen ------------------------------------------ */
.pos-register-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 900px) {
  /* Wider viewport unlocks the two-panel layout (product grid + cart
     side by side) instead of stacking - see
     pm/tanzanite-universe/tickets/POS-001-byod-pwa-strategy.md's
     "register view vs back-office view" responsive design note. */
  .pos-register-layout { grid-template-columns: 1fr 360px; align-items: start; }
}

.pos-search-row { margin-bottom: 10px; }
.pos-search-row input {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1.5px solid var(--pos-input-border);
  border-radius: 7px;
  background: var(--pos-white);
}
.pos-search-row input:focus {
  outline: none;
  border-color: var(--pos-primary);
  box-shadow: 0 0 0 3px rgba(44, 95, 138, 0.15);
}

.pos-category-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}
.pos-category-tab {
  flex: 0 0 auto;
  background: var(--pos-primary-light);
  color: var(--pos-primary-dark);
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 40px;
}
.pos-category-tab.active { background: var(--pos-primary); color: var(--pos-white); }

.pos-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.pos-product-card {
  background: var(--pos-white);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius);
  padding: 12px 10px;
  cursor: pointer;
  text-align: left;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.1s ease, transform 0.05s ease;
}
.pos-product-card:active { transform: scale(0.97); border-color: var(--pos-primary); }
.pos-product-name { font-weight: 700; font-size: 0.88rem; }
.pos-product-price { color: var(--pos-primary-dark); font-weight: 700; font-size: 0.9rem; margin-top: 6px; }
.pos-product-stock { font-size: 0.72rem; color: var(--pos-muted); margin-top: 2px; }
.pos-product-stock--low { color: var(--pos-warning); }
.pos-product-stock--out { color: var(--pos-danger); }

/* Cart panel */
.pos-cart {
  background: var(--pos-white);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius);
  padding: 14px 16px;
  position: sticky;
  top: 66px;
}
.pos-cart h2 { margin: 0 0 10px; font-size: 1.05rem; }
.pos-cart-empty { color: var(--pos-muted); font-size: 0.88rem; padding: 10px 0; }
.pos-cart-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--pos-border);
}
.pos-cart-row:last-child { border-bottom: none; }
.pos-cart-item-name { font-weight: 600; font-size: 0.85rem; }
.pos-cart-item-sub { font-size: 0.72rem; color: var(--pos-muted); }
.pos-qty-controls { display: flex; align-items: center; gap: 6px; }
.pos-qty-btn {
  width: 28px; height: 28px;
  border: 1px solid var(--pos-border);
  background: var(--pos-white);
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.pos-qty-value { min-width: 20px; text-align: center; font-weight: 600; }
.pos-cart-item-total { font-weight: 700; font-size: 0.85rem; white-space: nowrap; }
.pos-cart-remove { background: none; border: none; color: var(--pos-danger); cursor: pointer; font-size: 0.78rem; padding: 2px 4px; }

.pos-totals { margin-top: 12px; border-top: 1px solid var(--pos-border); padding-top: 10px; }
.pos-totals-row { display: flex; justify-content: space-between; font-size: 0.88rem; padding: 3px 0; }
.pos-totals-row--grand { font-size: 1.15rem; font-weight: 700; color: var(--pos-primary-dark); padding-top: 6px; }
.pos-discount-row { align-items: center; }
.pos-discount-input {
  width: 100px;
  font: inherit;
  font-size: 0.88rem;
  padding: 5px 8px;
  border: 1.5px solid var(--pos-input-border);
  border-radius: 6px;
  text-align: right;
}
.pos-discount-input:focus {
  outline: none;
  border-color: var(--pos-primary);
}

.pos-tender-row { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.pos-tender-row input {
  flex: 1;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 12px 14px;
  min-height: 48px;
}
.pos-tender-label { font-size: 0.85rem; font-weight: 600; color: var(--pos-muted); }
.pos-quick-amounts { display: flex; flex-wrap: wrap; gap: 6px; }
.pos-quick-amt {
  flex: 1 1 auto;
  min-width: 84px;
  padding: 10px 8px;
  font-size: 0.95rem;
  font-weight: 700;
  border: 1px solid var(--pos-border);
  border-radius: 6px;
  background: var(--pos-white);
  color: var(--pos-ink);
  cursor: pointer;
}
.pos-quick-amt:hover { background: var(--pos-primary-light); }
.pos-quick-amt--exact {
  border-color: var(--pos-primary);
  color: var(--pos-primary);
}
.pos-change-line { margin-top: 6px; font-size: 0.9rem; font-weight: 700; }
.pos-change-line--negative { color: var(--pos-danger); }

/* Drawer screens */
.pos-drawer-card {
  max-width: 420px;
  margin: 20px auto;
  background: var(--pos-white);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius);
  padding: 24px;
}
.pos-drawer-summary-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--pos-border); font-size: 0.9rem; }
.pos-drawer-summary-row:last-child { border-bottom: none; }
.pos-drawer-summary-row--variance { font-weight: 700; }

/* Receipt */
.pos-receipt {
  max-width: 380px;
  margin: 20px auto;
  background: var(--pos-white);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius);
  padding: 20px;
  font-family: "Courier New", Courier, monospace;
}
.pos-receipt h2 { text-align: center; margin: 0 0 4px; font-family: inherit; }
.pos-receipt-meta { text-align: center; font-size: 0.78rem; color: var(--pos-muted); margin-bottom: 12px; }
.pos-receipt-row { display: flex; justify-content: space-between; font-size: 0.85rem; padding: 2px 0; }
.pos-receipt-divider { border: none; border-top: 1px dashed var(--pos-border); margin: 8px 0; }
.pos-receipt-total { font-weight: 700; font-size: 1rem; }
.pos-receipt-actions { display: flex; gap: 8px; margin-top: 16px; }

@media print {
  .pos-header, .pos-receipt-actions { display: none !important; }
  body { background: var(--pos-white); }
  .pos-receipt { box-shadow: none; border: none; margin: 0; max-width: 100%; }
}

@media (max-width: 600px) {
  .pos-main { padding: 10px; }
  .pos-product-grid { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); }
  .btn { width: 100%; text-align: center; }
}

/* Manager screens (open drawers / sales history) shared chrome -------- */
.pos-drawer-card--wide { max-width: 720px; }
.pos-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.pos-panel-header h2 { margin: 0; }
.pos-checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; margin-bottom: 12px; cursor: pointer; }
.pos-checkbox-row input { width: 16px; height: 16px; }
.btn-sm { padding: 7px 12px; min-height: 34px; font-size: 0.82rem; }
.pos-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.pos-badge { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 0.72rem; font-weight: 700; }
.pos-badge--warn { background: #fdeecb; color: #8a5a00; }

.pos-drawer-list { display: flex; flex-direction: column; gap: 10px; }
.pos-drawer-row {
  border: 1px solid var(--pos-border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}
.pos-drawer-row--stale { border-color: #e8c179; background: #fffbf2; }
.pos-drawer-row-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pos-drawer-row-sub { font-size: 0.8rem; }
.pos-force-close-form { max-width: 100%; margin: 8px 0 0; padding: 16px; }

/* Idle lock overlay ------------------------------------------------------ */
.pos-lock-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 32, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 16px;
}
.pos-lock-card {
  background: var(--pos-white);
  border-radius: var(--pos-radius);
  padding: 28px 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}
.pos-lock-card h2 { margin: 8px 0 4px; }
.pos-lock-card .pos-form { margin-top: 14px; text-align: left; }

/* Sales history ----------------------------------------------------------- */
.pos-filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.pos-filter-row input { font: inherit; padding: 8px 10px; border: 1.5px solid var(--pos-input-border); border-radius: 7px; }
.pos-sales-list { display: flex; flex-direction: column; gap: 8px; }
.pos-sale-row {
  border: 1px solid var(--pos-border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: var(--pos-white);
}
.pos-sale-row:hover { border-color: var(--pos-primary); }
.pos-sale-row-main { display: flex; flex-direction: column; gap: 2px; }
.pos-sale-row-total { font-weight: 700; color: var(--pos-primary-dark); }
.pos-pagination { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }

/* Payment method tabs + QR ------------------------------------------------- */
.pos-paymethod-tabs { display: flex; gap: 6px; margin-top: 12px; }
.pos-paymethod-tab {
  flex: 1;
  background: var(--pos-primary-light);
  color: var(--pos-primary-dark);
  border: none;
  border-radius: 7px;
  padding: 10px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  min-height: 40px;
}
.pos-paymethod-tab.active { background: var(--pos-primary); color: var(--pos-white); }
.pos-qr-wrap { text-align: center; margin-top: 14px; padding: 14px; border: 1px dashed var(--pos-border); border-radius: 10px; }
.pos-qr-wrap img { width: 180px; height: 180px; margin: 0 auto; display: block; background: var(--pos-white); }
.pos-qr-status { margin-top: 10px; font-size: 0.85rem; font-weight: 600; }
.pos-qr-status--waiting { color: var(--pos-muted); }
.pos-qr-status--success { color: #1e7e34; }
.pos-qr-status--failed { color: var(--pos-danger); }
.pos-mobile-ref { font-family: "Courier New", Courier, monospace; font-weight: 700; letter-spacing: 0.5px; }
