:root {
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-alt: #f8faf9;
  --border: #dce4e1;
  --text: #10211f;
  --text-muted: #546966;
  --sidebar-bg: #102a27;
  --sidebar-text: #eaf4f1;
  --accent: #139a6e;
  --accent-strong: #0d7a56;
  --accent-soft: #e3f7ef;
  --pulse: #2be59d;
  --danger: #c93b3b;
  --danger-soft: #fdecec;
  --warn: #b4690e;
  --warn-soft: #fff4e5;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(16, 33, 31, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body[data-accent="blue"] {
  --accent: #1d6fe8;
  --accent-strong: #1557bc;
  --accent-soft: #e8f1fe;
}
body[data-accent="amber"] {
  --accent: #c97310;
  --accent-strong: #a35a08;
  --accent-soft: #fef3e2;
}
body[data-accent="slate"] {
  --accent: #334155;
  --accent-strong: #1e293b;
  --accent-soft: #eef2f6;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
}
.brand-mark { width: 34px; height: 34px; flex: none; display: inline-flex; }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-title { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.vp-pulse { color: var(--pulse); }
.brand-badge { display: inline-block; font-size: 10px; letter-spacing: 0.08em; opacity: 0.78; font-weight: 700; }

.nav-list { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: rgba(234, 244, 241, 0.86);
  font-weight: 600;
  transition: background 0.15s ease;
}
.nav-btn:hover { background: rgba(255, 255, 255, 0.08); }
.nav-btn.active { background: var(--accent); color: #ffffff; }
.nav-dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; opacity: 0.65; flex: none; }
.nav-btn.active .nav-dot { opacity: 1; }

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 12px;
  font-size: 12px;
}
.status-pill { font-weight: 700; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-meta { opacity: 0.72; font-size: 11px; }

.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px 20px 28px;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar-left h1 { margin: 0; font-size: 21px; font-weight: 800; }
.topbar-left p { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.hw-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.view-root { min-width: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  min-height: 38px;
}
.btn:hover:not(:disabled) { background: var(--surface-alt); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #ffffff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #ffffff; }
.btn-sm { padding: 5px 10px; min-height: 30px; font-size: 12px; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  min-height: 38px;
}
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 700; color: var(--text-muted); }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
}
.check-row input { width: 17px; height: 17px; accent-color: var(--accent); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* Checkout Layout */
.checkout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.95fr);
  gap: 16px;
  align-items: start;
}

.scan-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.scan-bar .input { flex: 1; font-size: 15px; min-height: 42px; }

.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 12px;
  font-weight: 600;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 10px;
}
.product-tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
  transition: border-color 0.12s ease, transform 0.08s ease;
}
.product-tile:hover { border-color: var(--accent); }
.product-tile:active { transform: scale(0.985); }
.product-tile.out-of-stock { opacity: 0.68; }
.product-tile-name { font-weight: 700; line-height: 1.25; }
.product-tile-meta { font-size: 11px; color: var(--text-muted); }
.product-tile-bottom { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.product-price { font-weight: 800; color: var(--accent-strong); font-size: 15px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.badge-warn { background: var(--warn-soft); border-color: #f3d2a2; color: var(--warn); }
.badge-danger { background: var(--danger-soft); border-color: #f4bebe; color: var(--danger); }
.badge-ok { background: var(--accent-soft); border-color: #b5e7d5; color: var(--accent-strong); }

.cart-panel {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cart-header { display: flex; justify-content: space-between; align-items: center; }
.cart-header h2 { margin: 0; font-size: 16px; }

.cart-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 330px;
  overflow-y: auto;
}
.cart-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-alt);
}
.cart-row-name { font-weight: 700; font-size: 13px; }
.cart-row-sub { font-size: 11px; color: var(--text-muted); }
.qty-stepper { display: inline-flex; align-items: center; gap: 6px; }
.qty-stepper span { min-width: 24px; text-align: center; font-weight: 700; }

.totals-box {
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.total-line { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-muted); }
.total-line.grand { font-size: 19px; font-weight: 800; color: var(--text); padding-top: 4px; border-top: 1px solid var(--border); }

.payment-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pay-tab {
  padding: 8px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-weight: 700;
  font-size: 12px;
}
.pay-tab.active { background: var(--accent); border-color: var(--accent); color: #ffffff; }

.quick-cash { display: flex; gap: 6px; flex-wrap: wrap; }

/* KPI & Tables */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
}
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.kpi-value { font-size: 21px; font-weight: 800; margin-top: 4px; }

.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th, table.data-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
table.data-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
table.data-table tr:hover td { background: var(--surface-alt); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.empty-state {
  padding: 26px 16px;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface-alt);
}

/* Modal & Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 33, 31, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}
.modal-dialog {
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--border);
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.toast-host {
  position: fixed;
  right: 16px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1200;
}
.toast {
  background: #102a27;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
}
.toast.error { background: var(--danger); }

/* Receipt Preview & Print */
.receipt-preview-box {
  background: #f5f5f5;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  justify-content: center;
}
.pos-print-receipt {
  background: #ffffff;
  color: #000000;
  width: 100%;
  max-width: 310px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  line-height: 1.35;
}
.pos-print-receipt header, .pos-print-receipt footer { text-align: center; }
.pos-print-receipt h1 { margin: 0 0 4px; font-size: 15px; }
.pos-print-receipt p { margin: 2px 0; }
.pos-print-receipt hr.receipt-divider { border: 0; border-top: 1px dashed #444; margin: 8px 0; }
.print-line, .print-detail { display: flex; justify-content: space-between; gap: 8px; margin: 3px 0; }
.print-line small { display: block; color: #444; font-size: 11px; }
.print-total { font-size: 14px; font-weight: 800; margin-top: 5px; }
.receipt-reprint-banner { text-align: center; font-weight: 800; letter-spacing: 0.08em; margin: 4px 0; }

#vpSimplePrintArea { display: none; }

.camera-video { width: 100%; border-radius: 10px; background: #000; max-height: 320px; object-fit: cover; }

.mobile-bottom-nav { display: none; }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-area { padding: 12px 12px 76px; }
  .checkout-grid, .two-col { grid-template-columns: 1fr; }
  .cart-panel { position: static; }
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--sidebar-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    z-index: 900;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .mob-nav-btn {
    border: 0;
    background: transparent;
    color: rgba(234, 244, 241, 0.78);
    padding: 11px 4px;
    font-size: 12px;
    font-weight: 700;
  }
  .mob-nav-btn.active { color: var(--pulse); background: rgba(255, 255, 255, 0.08); }
  .toast-host { bottom: 68px; right: 12px; left: 12px; }
}

@media print {
  body > *:not(#vpSimplePrintArea) { display: none !important; }
  #vpSimplePrintArea {
    display: block !important;
    width: var(--vp-print-content-w, 71mm);
    margin: 0 auto;
    padding: var(--vp-print-pad-y, 2mm) var(--vp-print-pad-x, 2mm);
    font-size: var(--vp-print-font-size, 12px);
    color: #000 !important;
    background: #fff !important;
  }
  #vpSimplePrintArea .pos-print-receipt {
    max-width: none;
    width: 100%;
    padding: 0;
    font-size: inherit;
  }
}
