:root {
  color-scheme: light;
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --sidebar: #101828;
  --sidebar-hover: #1d2939;
  --shadow: 0 10px 30px rgba(16, 24, 40, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 700; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top right, #dbeafe, transparent 40%), #0f172a; }
.login-card { width: min(430px, 100%); background: var(--surface); border-radius: 22px; padding: 32px; box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.brand-lockup { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.brand-mark { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 25px; background: #dbeafe; }
.brand-lockup h1 { font-size: 22px; margin: 0; }
.brand-lockup p { margin: 4px 0 0; color: var(--muted); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 245px 1fr; }
.sidebar { background: var(--sidebar); color: white; padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-brand { display: flex; gap: 11px; align-items: center; padding: 8px 10px 20px; border-bottom: 1px solid rgba(255,255,255,.09); margin-bottom: 14px; }
.sidebar-brand .brand-mark { width: 40px; height: 40px; border-radius: 11px; }
.sidebar-brand strong { display: block; }
.sidebar-brand span { display: block; color: #98a2b3; font-size: 12px; margin-top: 3px; }
.nav { display: grid; gap: 5px; }
.nav-button { width: 100%; border: 0; background: transparent; color: #d0d5dd; text-align: left; padding: 11px 12px; border-radius: 10px; display: flex; align-items: center; gap: 10px; }
.nav-button:hover, .nav-button.active { background: var(--sidebar-hover); color: white; }
.nav-button .icon { width: 23px; text-align: center; }
.sidebar-footer { margin-top: 22px; border-top: 1px solid rgba(255,255,255,.09); padding: 15px 10px 0; color: #98a2b3; font-size: 12px; }

.main { min-width: 0; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 26px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar h2 { margin: 0; font-size: 20px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-chip { padding: 8px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; font-size: 13px; }
.content { padding: 24px; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-header h1 { margin: 0; font-size: 26px; }
.page-header p { margin: 5px 0 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 9px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.card-header { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-header h3 { margin: 0; font-size: 16px; }
.card-body { padding: 20px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric { padding: 20px; }
.metric .label { color: var(--muted); font-size: 13px; }
.metric .value { font-size: 28px; font-weight: 800; margin-top: 10px; letter-spacing: -.03em; }
.metric .hint { margin-top: 8px; font-size: 12px; color: var(--muted); }

.btn { border: 1px solid transparent; border-radius: 10px; padding: 10px 14px; font-weight: 650; background: var(--surface); color: var(--text); }
.btn:hover { filter: brightness(.98); }
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { border-color: var(--line); }
.btn-sm { padding: 7px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 650; }
.input, .select, .textarea { width: 100%; border: 1px solid #d0d5dd; background: white; border-radius: 10px; padding: 10px 12px; color: var(--text); outline: none; }
.input:focus, .select:focus, .textarea:focus { border-color: #84adff; box-shadow: 0 0 0 3px #dbeafe; }
.textarea { min-height: 90px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; vertical-align: middle; }
th { color: #475467; background: #f9fafb; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 5px 9px; font-weight: 700; font-size: 11px; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #ffedd5; color: #9a3412; }
.badge-info { background: #dbeafe; color: #1e40af; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input { max-width: 360px; }
.empty { text-align: center; padding: 45px 18px; color: var(--muted); }

.pos-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(360px, .8fr); gap: 18px; align-items: start; }
.pos-search { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.product-grid { margin-top: 15px; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; max-height: calc(100vh - 270px); overflow-y: auto; padding-right: 4px; }
.product-card { border: 1px solid var(--line); background: white; border-radius: 13px; padding: 14px; text-align: left; min-height: 125px; display: flex; flex-direction: column; }
.product-card:hover { border-color: #84adff; box-shadow: 0 5px 18px rgba(37,99,235,.12); }
.product-card .name { font-weight: 750; line-height: 1.25; }
.product-card .barcode { color: var(--muted); font-size: 11px; margin-top: 5px; }
.product-card .price { font-size: 18px; font-weight: 800; margin-top: auto; padding-top: 12px; }
.product-card .stock { font-size: 11px; color: var(--muted); margin-top: 4px; }
.cart-card { position: sticky; top: 92px; }
.cart-items { max-height: 330px; overflow-y: auto; }
.cart-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cart-row:last-child { border-bottom: 0; }
.cart-row .title { font-weight: 700; font-size: 13px; }
.cart-row .meta { color: var(--muted); font-size: 11px; margin-top: 3px; }
.qty-control { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.qty-control button { width: 28px; height: 28px; border: 1px solid var(--line); background: white; border-radius: 8px; }
.qty-control input { width: 52px; height: 28px; border: 1px solid var(--line); border-radius: 8px; text-align: center; }
.totals { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 13px; display: grid; gap: 8px; }
.total-line { display: flex; justify-content: space-between; font-size: 13px; }
.total-line.grand { font-size: 23px; font-weight: 850; padding-top: 9px; border-top: 1px dashed #d0d5dd; }
.payment-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 14px 0; }
.pay-option { border: 1px solid var(--line); border-radius: 10px; padding: 9px; background: white; font-size: 12px; font-weight: 700; }
.pay-option.active { border-color: var(--brand); background: #eff6ff; color: #1d4ed8; }
.shortcut-hint { font-size: 10px; color: var(--muted); display: block; margin-top: 2px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: grid; place-items: center; z-index: 50; padding: 18px; }
.modal { background: white; width: min(720px, 100%); max-height: 92vh; overflow: auto; border-radius: 18px; box-shadow: 0 30px 90px rgba(0,0,0,.35); }
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { margin: 0; }
.modal-body { padding: 20px; }
.icon-button { border: 0; background: transparent; font-size: 22px; }

.toast { position: fixed; right: 22px; bottom: 22px; max-width: 390px; background: #101828; color: white; padding: 13px 16px; border-radius: 11px; box-shadow: var(--shadow); z-index: 100; }
.toast.error { background: #991b1b; }
.toast.success { background: #166534; }

.receipt { width: 80mm; margin: 0 auto; color: #000; background: #fff; font-family: "Courier New", monospace; font-size: 12px; padding: 8px; }
.receipt h2, .receipt p { text-align: center; margin: 4px 0; }
.receipt-line { display: flex; justify-content: space-between; gap: 10px; margin: 3px 0; }
.receipt-rule { border-top: 1px dashed #000; margin: 7px 0; }

@media (max-width: 1050px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .pos-layout { grid-template-columns: 1fr; }
  .cart-card { position: static; }
  .product-grid { max-height: none; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { grid-template-columns: repeat(3, 1fr); }
  .nav-button { justify-content: center; text-align: center; flex-direction: column; font-size: 11px; }
  .sidebar-footer { display: none; }
  .topbar { padding: 0 15px; }
  .content { padding: 15px; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .page-header { flex-direction: column; }
}
@media print {
  body * { visibility: hidden !important; }
  #print-area, #print-area * { visibility: visible !important; }
  #print-area { position: absolute; inset: 0; margin: 0; }
  .modal-backdrop { position: static; background: white; padding: 0; }
  .modal { box-shadow: none; width: auto; max-height: none; }
  .modal-header, .receipt-actions { display: none !important; }
}

/* v1.1 keyboard-only cashier enhancements */
.keyboard-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  margin: -6px 0 16px;
  padding: 10px 14px;
  background: #101828;
  color: #e4e7ec;
  border-radius: 12px;
  font-size: 11px;
}
.keyboard-strip span { white-space: nowrap; }
kbd {
  display: inline-block;
  min-width: 27px;
  padding: 3px 6px;
  margin-right: 4px;
  border: 1px solid #667085;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #344054;
  color: white;
  font: 700 10px/1.2 system-ui, sans-serif;
  text-align: center;
}
.scanner-input {
  font-size: 18px;
  font-weight: 750;
  letter-spacing: .02em;
  border-width: 2px;
}
.scanner-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px #dbeafe;
}
.product-card.keyboard-selected {
  border: 2px solid #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 3px #bfdbfe, 0 8px 22px rgba(37,99,235,.16);
}
.cart-row.keyboard-selected {
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
  border-radius: 10px;
  background: #eff6ff;
  box-shadow: inset 4px 0 0 #2563eb;
}
.payment-input { font-size: 20px; font-weight: 800; }
.keyboard-modal-hint {
  margin-top: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
