.hidden { display: none !important; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  background: #f1f5f9;
}

.pos-app {
  display: grid;
  grid-template-columns: 0 1fr 340px;
  height: 100vh;
  transition: grid-template-columns 0.25s ease;
}

body.sidebar-pinned .pos-app {
  grid-template-columns: 220px 1fr 340px;
}

body.sidebar-pinned.sidebar-rail .pos-app {
  grid-template-columns: 72px 1fr 340px;
}

/* Sidebar drawer */
.pos-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 900;
}
.pos-sidebar-backdrop.active { display: block; }

.pos-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(280px, 88vw);
  z-index: 950;
  background: #1e293b;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateX(-100%);
  transition: transform 0.25s ease, width 0.25s ease;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
  grid-column: 1;
  grid-row: 1;
}
.pos-sidebar.open {
  transform: translateX(0);
}

/* 釘選：工作列常駐，縮窄時保留 emoji 圖示 */
body.sidebar-pinned .pos-sidebar {
  position: relative;
  transform: translateX(0) !important;
  width: 100%;
  min-width: 0;
  box-shadow: none;
}
body.sidebar-pinned .pos-sidebar-backdrop {
  display: none !important;
}
body.sidebar-pinned.sidebar-rail .pos-sidebar {
  padding: 12px 8px;
}
body.sidebar-pinned.sidebar-rail .pos-sidebar__brand {
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
body.sidebar-pinned.sidebar-rail .pos-sidebar__meta,
body.sidebar-pinned.sidebar-rail .pos-nav__label,
body.sidebar-pinned.sidebar-rail .pos-nav__item > span:not(.pos-nav__icon),
body.sidebar-pinned.sidebar-rail .pos-toggle-row > span,
body.sidebar-pinned.sidebar-rail .pos-sidebar__user,
body.sidebar-pinned.sidebar-rail .pos-sidebar__logout,
body.sidebar-pinned.sidebar-rail .pos-sidebar__powered {
  display: none !important;
}
body.sidebar-pinned.sidebar-rail .pos-nav__item {
  justify-content: center;
  padding: 10px 8px;
}
body.sidebar-pinned.sidebar-rail .pos-nav__icon {
  width: auto;
  font-size: 20px;
}
body.sidebar-pinned.sidebar-rail .pos-toggle-row {
  justify-content: center;
  padding: 8px 4px;
}
body.sidebar-pinned.sidebar-rail .pos-sidebar__pin {
  margin: 0;
}

.pos-main-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.pos-menu-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}
.pos-menu-btn__bar {
  display: block;
  height: 2px;
  background: #334155;
  border-radius: 2px;
}
.pos-main-header__mode {
  font-weight: 700;
  font-size: 16px;
  color: #0f172a;
}
.pos-main-header__search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(360px, 48vw);
  flex-shrink: 1;
}
.pos-main-header__search input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px 9px 36px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242 1.1a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") 12px center no-repeat;
}
.pos-btn-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
}
.pos-main-header__user {
  margin-left: 12px;
  font-size: 13px;
  color: #64748b;
  white-space: nowrap;
  flex-shrink: 0;
}

.pos-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f8fafc;
  grid-column: 2;
  min-width: 0;
}
.pos-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 0 4px;
  flex-shrink: 0;
}
.pos-sidebar__logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}
.pos-sidebar__meta {
  flex: 1;
  min-width: 0;
}
.pos-sidebar__pin {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.12s;
}
.pos-sidebar__pin:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
}
.pos-sidebar__pin.is-pinned {
  background: #3b82f6;
  border-color: #60a5fa;
  color: #fff;
}
.pos-sidebar__name {
  color: #f8fafc;
  font-weight: 700;
  font-size: 14px;
  margin: 0;
}
.pos-sidebar__badge {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
}
.pos-nav__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #64748b;
  margin: 16px 8px 8px;
}
.pos-nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.pos-nav__item:hover { background: rgba(255,255,255,0.06); color: #f1f5f9; }
.pos-nav__item.active {
  background: #3b82f6;
  color: #fff;
}
.pos-nav__icon { width: 18px; text-align: center; opacity: 0.9; }
.pos-nav__link {
  text-decoration: none;
  display: flex;
}
.pos-sidebar__footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
}
.pos-sidebar__user { color: #e2e8f0; font-weight: 600; }
.pos-sidebar__logout {
  color: #f87171;
  background: none;
  border: none;
  padding: 0;
  margin-top: 6px;
  cursor: pointer;
  font-size: 13px;
}
.pos-sidebar__powered {
  margin-top: 12px;
  font-size: 10px;
  color: #64748b;
}
.pos-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  color: #cbd5e1;
  font-size: 14px;
}
.pos-switch {
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: #475569;
  border: none;
  cursor: pointer;
  position: relative;
}
.pos-switch.on { background: #3b82f6; }
.pos-switch::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
}
.pos-switch.on::after { transform: translateX(18px); }

.pos-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.pos-pill {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.pos-pill.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}
.pos-toolbar__sort {
  margin-left: auto;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  font-size: 14px;
}
.pos-products {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  align-content: start;
}
.pos-product-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 2px solid transparent;
}
.pos-product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.pos-product-card.selected { border-color: #3b82f6; }
.pos-product-card__img {
  position: relative;
  aspect-ratio: 1;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pos-product-card__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pos-product-card__stock {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pos-product-card__price {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(15,23,42,0.85);
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}
.pos-product-card__body { padding: 10px 12px 12px; }
.pos-product-card__name {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.3;
}
.pos-product-card__code {
  margin: 4px 0 0;
  font-size: 12px;
  color: #94a3b8;
}

/* Panel (center alternate views) */
.pos-panel-view {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: none;
}
.pos-panel-view.active { display: block; }

/* Order column */
.pos-order {
  grid-column: 3;
  background: #fff;
  border-left: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}
.pos-order__head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
}
.pos-order__title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pos-badge-sale {
  background: #3b82f6;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}
.pos-order__clear {
  border: none;
  background: none;
  color: #64748b;
  font-size: 13px;
  cursor: pointer;
}
.pos-order__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.pos-order__items {
  flex: 1;
  padding: 0 12px;
  min-height: 60px;
}
.pos-order__empty {
  color: #cbd5e1;
  text-align: center;
  padding: 40px 16px;
  font-size: 15px;
}
.pos-cart-line {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}
.pos-cart-line__info { flex: 1; min-width: 0; }
.pos-cart-line__name { font-weight: 600; margin: 0; }
.pos-cart-line__meta { color: #94a3b8; font-size: 12px; }
.pos-cart-line__qty {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pos-cart-line__qty button {
  width: 26px;
  height: 26px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.pos-order__footer {
  flex-shrink: 0;
  padding: 10px 12px 12px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.08);
  z-index: 20;
}
.pos-checkout-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin-bottom: 8px;
}
.pos-field-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px;
  margin: 0;
  min-width: 0;
}
.pos-field-row--discount {
  grid-template-columns: auto 1fr;
}
.pos-field-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
}
.pos-field-label--sm {
  font-size: 11px;
  font-weight: 500;
}
.pos-order__checkout select,
.pos-order__checkout input[type="number"] {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  margin: 0;
  background: #fff;
}
.pos-order__discount-wrap {
  position: relative;
  display: block;
  min-width: 0;
}
.pos-order__discount-wrap input {
  padding-right: 22px !important;
}
.pos-field-suffix {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 12px;
  pointer-events: none;
}
.pos-btn-note {
  width: 100%;
  padding: 7px 10px;
  margin-bottom: 8px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #64748b;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
}
.pos-btn-note.has-note {
  border-color: #3b82f6;
  color: #3b82f6;
  background: #eff6ff;
}
.pos-order__summary--compact {
  margin: 0 0 8px;
  font-size: 13px;
}
.pos-order__summary--compact div {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
  color: #64748b;
}
.pos-order__summary--compact .total {
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid #e2e8f0;
}
.pos-order__summary {
  margin: 12px 0;
  font-size: 14px;
}
.pos-order__summary div {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  color: #64748b;
}
.pos-order__summary .total {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
  margin-top: 8px;
}

/* 訂單備註彈層 */
.pos-note-popover {
  position: fixed;
  inset: 0;
  z-index: 1800;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
}
.pos-note-popover:not(.hidden) {
  pointer-events: auto;
}
.pos-note-popover.hidden {
  display: none !important;
}
.pos-note-popover__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
}
.pos-note-popover__panel {
  position: relative;
  width: min(400px, 100%);
  background: #fff;
  border-radius: 16px 16px 12px 12px;
  padding: 16px;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
  z-index: 1;
}
.pos-note-popover__title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
}
.pos-note-popover__panel textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 72px;
  margin-bottom: 10px;
}
.pos-note-popover__done {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}
.pos-btn-charge {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: #3b82f6;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.pos-btn-charge:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.pos-btn-charge:hover:not(:disabled) { background: #2563eb; }

/* Modal */
.pos-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 1100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.pos-modal.active { display: flex !important; }
body.checkout-open #checkoutModal {
  display: flex !important;
  z-index: 2000;
}
#checkoutModal { z-index: 2000; }
#loginModal { z-index: 1900; }
.pos-modal__box {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: min(400px, 100%);
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.pos-modal__box h2 { margin: 0 0 16px; font-size: 20px; }
.pos-modal__box label { display: block; font-size: 12px; font-weight: 600; color: #64748b; margin-bottom: 4px; }
.pos-modal__box input, .pos-modal__box select {
  width: 100%;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.pos-modal__actions { display: flex; gap: 8px; margin-top: 8px; }
.pos-modal__actions button {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  cursor: pointer;
}
.pos-btn-primary { background: #3b82f6; color: #fff; }
.pos-btn-secondary { background: #e2e8f0; color: #334155; }
.pos-modal__hint {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.5;
  color: #64748b;
}
.pos-modal__btn-secondary {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #334155;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.pos-modal__btn-secondary:hover { background: #f1f5f9; }
.pos-modal__btn-confirm { flex: 1; }
#resetDisplayModal { z-index: 1850; }

.pos-btn-reset-display {
  flex-shrink: 0;
  padding: 8px 14px;
  border: none;
  border-radius: 999px;
  background: #16a34a;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.pos-btn-reset-display:hover { background: #15803d; }
.pos-btn-reset-display:active { background: #166534; }

.pos-btn-discount {
  width: 100%;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.pos-btn-discount:hover {
  border-color: #cbd5e1;
  background: #fff;
}
.pos-btn-discount.has-value {
  color: #0f172a;
  border-color: #93c5fd;
  background: #eff6ff;
}
.pos-btn-discount:not(.has-value) {
  color: #64748b;
}
.pos-discount-panel { padding: 20px; border-radius: 16px; }
.pos-discount-panel__hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: #64748b;
}
.pos-discount-input-wrap {
  position: relative;
  display: block;
  margin-bottom: 16px;
}
.pos-btn-discount-clear {
  color: #dc2626;
  border: 1px solid #fecaca;
  background: #fef2f2;
}
.pos-btn-discount-clear:hover {
  border-color: #fca5a5;
  background: #fee2e2;
}
.pos-discount-input-wrap input {
  width: 100%;
  padding: 14px 36px 14px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-size: 22px;
  font-weight: 600;
  font-family: inherit;
  margin: 0;
}
.pos-discount-input-wrap input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.pos-discount-input-suffix {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 18px;
  font-weight: 600;
  pointer-events: none;
}
.pos-discount-modal__actions {
  display: flex;
  gap: 10px;
}
.pos-discount-modal__actions button {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  border: none;
}
.pos-discount-modal__actions .pos-modal__btn-secondary {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}
.pos-discount-modal__actions .pos-btn-discount-clear {
  border: 1px solid #fecaca;
}
.pos-discount-modal__actions .pos-btn-primary {
  border: none;
}

/* Checkout modal */
.pos-checkout {
  background: #fff;
  border-radius: 20px;
  padding: 24px 28px;
  width: min(560px, 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
}
.pos-checkout__title {
  margin: 0 0 20px;
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
}
.pos-checkout__body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.pos-checkout__summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pos-checkout__row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pos-checkout__label {
  font-size: 13px;
  color: #64748b;
  font-weight: 600;
}
.pos-checkout__amount {
  font-size: 36px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
}
.pos-checkout__exact {
  width: 100%;
  padding: 12px 16px;
  margin: 8px 0;
  border: 2px solid #3b82f6;
  border-radius: 999px;
  background: #fff;
  color: #3b82f6;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.pos-checkout__exact:hover {
  background: #eff6ff;
}
.pos-checkout__row--change { margin-top: 8px; }
.pos-checkout__change {
  font-size: 36px;
  font-weight: 800;
  color: #16a34a;
}
.pos-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.pos-keypad button {
  padding: 16px;
  border: none;
  border-radius: 12px;
  background: #f1f5f9;
  color: #334155;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.pos-keypad button:hover { background: #e2e8f0; }
.pos-keypad button:active { background: #cbd5e1; }
.pos-keypad__back {
  background: #fee2e2 !important;
  color: #b91c1c !important;
}
.pos-checkout__actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  grid-column: 1 / -1;
}
.pos-checkout__cancel {
  border: none;
  background: none;
  color: #64748b;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px;
}
.pos-checkout__confirm {
  padding: 12px 28px;
  border: none;
  border-radius: 999px;
  background: #3b82f6;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.pos-checkout__confirm:hover:not(:disabled) { background: #2563eb; }
.pos-checkout__confirm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  .pos-checkout__body {
    grid-template-columns: 1fr;
  }
  .pos-checkout__actions {
    flex-direction: column-reverse;
    gap: 12px;
  }
  .pos-checkout__confirm { width: 100%; }
}

/* Toast & loading */
.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pos-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #1e293b;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.pos-toast--success { background: #16a34a; }
.pos-toast--error { background: #dc2626; }
.pos-toast button { background: none; border: none; color: inherit; cursor: pointer; font-size: 18px; }
.pos-loading {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.82);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.pos-loading.active { display: flex; }
.pos-loading__card { text-align: center; }
.pos-loading__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Data panels */
.pos-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.pos-stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.pos-stat-card__val { font-size: 24px; font-weight: 800; color: #3b82f6; }
.pos-stat-card__lbl { font-size: 12px; color: #64748b; margin-top: 4px; }
.pos-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  font-size: 13px;
}
.pos-table th, .pos-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
}
.pos-table th { background: #f8fafc; color: #64748b; font-size: 11px; text-transform: uppercase; }
.pos-form-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  max-width: 480px;
}
.pos-form-card label { display: block; font-size: 12px; font-weight: 600; color: #64748b; margin: 8px 0 4px; }
.pos-form-card input, .pos-form-card select, .pos-form-card textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.pos-inv-panel {
  flex-shrink: 0;
  padding: 12px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}
.pos-inv-panel input { width: 100%; padding: 10px; margin-bottom: 8px; border-radius: 8px; border: 1px solid #e2e8f0; }

@media (max-width: 1024px) {
  .pos-app { grid-template-columns: 0 1fr minmax(260px, 34vw); }
  body.sidebar-pinned .pos-app { grid-template-columns: 220px 1fr minmax(260px, 34vw); }
  body.sidebar-pinned.sidebar-rail .pos-app { grid-template-columns: 72px 1fr minmax(260px, 34vw); }
  .pos-order__footer {
    padding: 8px 10px 10px;
  }
  .pos-checkout-fields {
    gap: 6px 8px;
  }
  .pos-btn-charge {
    padding: 12px;
    font-size: 15px;
  }
}

/* 平板直向／窄螢幕：訂單欄改為底部抽屜，優先顯示結帳區 */
@media (max-width: 900px) {
  .pos-app {
    grid-template-columns: 0 1fr;
    grid-template-rows: 1fr auto;
  }
  body.sidebar-pinned .pos-app {
    grid-template-columns: 72px 1fr;
    grid-template-rows: 1fr auto;
  }
  body.sidebar-pinned:not(.sidebar-rail) .pos-app {
    grid-template-columns: 200px 1fr;
  }
  .pos-sidebar {
    grid-column: 1;
    grid-row: 1 / -1;
  }
  body.sidebar-pinned .pos-sidebar {
    position: relative;
  }
  .pos-main {
    grid-column: 2;
    grid-row: 1;
    min-height: 0;
    height: calc(100vh - min(280px, 38vh));
  }
  .pos-order {
    grid-column: 2;
    grid-row: 2;
  }
  .pos-order {
    position: relative;
    height: auto;
    max-height: min(380px, 42vh);
    min-height: 240px;
    border-left: none;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
  }
  .pos-order__scroll {
    max-height: 100px;
    flex: 0 1 auto;
  }
  .pos-order__footer {
    flex: 0 0 auto;
  }
  .pos-note-popover {
    align-items: center;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 768px) {
  .pos-main-header__search {
    width: min(200px, 35vw);
  }
  .pos-main {
    height: calc(100vh - min(300px, 45vh));
  }
  .pos-order {
    max-height: min(320px, 48vh);
    min-height: 260px;
  }
  .pos-order__scroll {
    max-height: 90px;
  }
  .pos-checkout-fields {
    grid-template-columns: 1fr 1fr;
  }
}
