/* EZ Mart POS — White + Red (Makro / 7-Eleven style) + CosyPOS layout */
:root,
[data-theme="light"] {
  --brand: #E30613;
  --brand-dark: #B9050F;
  --brand-light: #FEE2E2;
  --accent-blue: #2563EB;
  --charcoal: #1F2937;
  --text-muted: #64748B;
  --surface: #FFFFFF;
  --surface-muted: #F8FAFC;
  --border: #E2E8F0;
  --sidebar-collapsed: 4.5rem;
  --sidebar-expanded: 15.5rem;
  --pg-purple: #7C3AED;
}

[data-theme="dark"] {
  --brand: #EF4444;
  --brand-dark: #DC2626;
  --brand-light: #450A0A;
  --charcoal: #F1F5F9;
  --text-muted: #94A3B8;
  --surface: #1E293B;
  --surface-muted: #0F172A;
  --border: #334155;
}

body {
  font-family: 'Prompt', 'Inter', sans-serif;
  background: var(--surface-muted);
  color: var(--charcoal);
  min-height: 100vh;
}

.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(227, 6, 19, 0.04);
}

[data-theme="dark"] .glass {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

/* Buttons (DaisyUI-compatible) */
.btn {
  min-height: 44px;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  font-weight: 700;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(227, 6, 19, 0.3);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--charcoal);
}

.btn-outline:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  border-radius: 9999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
}

/* ── Collapsible Sidebar ── */
.sidebar {
  width: var(--sidebar-collapsed);
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar.is-expanded,
.sidebar:hover {
  width: var(--sidebar-expanded);
}

.sidebar-brand-text,
.sidebar-link-text,
.sidebar-footer-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.2s ease, width 0.28s ease;
}

.sidebar.is-expanded .sidebar-brand-text,
.sidebar.is-expanded .sidebar-link-text,
.sidebar.is-expanded .sidebar-footer-text,
.sidebar:hover .sidebar-brand-text,
.sidebar:hover .sidebar-link-text,
.sidebar:hover .sidebar-footer-text {
  opacity: 1;
  width: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem;
  margin: 0.1rem 0.4rem;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: all 0.2s ease;
  position: relative;
  min-height: 2.5rem;
}

.sidebar-link:hover {
  background: var(--brand-light);
  color: var(--brand);
}

.sidebar-link.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(227, 6, 19, 0.28);
}

.sidebar-link.active:hover {
  background: var(--brand-dark);
  color: #fff;
}

.sidebar-link-accent .sidebar-icon-wrap {
  color: var(--brand);
}

.sidebar-link-accent:hover .sidebar-icon-wrap,
.sidebar-link.active .sidebar-icon-wrap {
  color: inherit;
}

/* ── เมนูย่อย (Sub-menu) — Minimal text-only + badge, ไม่มีไอคอน ── */
/* ซ่อนตอน sidebar ยุบ (ไม่มีไอคอนให้แสดง) — โผล่ตอน hover/expand/mobile-open */
.sidebar-sublink {
  display: none;
  align-items: center;
  gap: 0.5rem;
  /* เข้าชุดกับ label ของเมนูหลัก: padding(0.55) + ไอคอน(2.25) + gap(0.6) */
  padding: 0.35rem 0.55rem 0.35rem 3.4rem;
  margin: 0.05rem 0.4rem;
  border-radius: 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  min-height: 1.9rem;
  transition: color 0.18s ease, background 0.18s ease;
}

.sidebar.is-expanded .sidebar-sublink,
.sidebar:hover .sidebar-sublink {
  display: flex;
}

.sidebar-sublink:hover {
  color: var(--brand);
  background: var(--brand-light);
}

.sidebar-sublink.active {
  color: var(--brand);
  font-weight: 800;
}

.sidebar-sublink-badge {
  margin-left: auto;
  min-width: 1.2rem;
  height: 1.15rem;
  padding: 0 0.32rem;
  border-radius: 9999px;
  background: #7c3aed;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-sublink-badge.hidden {
  display: none;
}

/* ── Draft Bills alert ── */
.draft-top-alert {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-radius: 9999px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.draft-top-alert.is-active,
.draft-top-alert[x-show] {
  display: inline-flex;
}

.draft-top-alert:hover {
  background: #fee2e2;
  box-shadow: 0 2px 8px rgba(227, 6, 19, 0.15);
}

.draft-top-alert-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: var(--brand);
  animation: draft-pulse 1.5s ease-in-out infinite;
}

@keyframes draft-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

.draft-alert-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-radius: 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 0.875rem;
  font-weight: 600;
}

.draft-alert-dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 9999px;
  background: var(--brand);
  flex-shrink: 0;
  animation: draft-pulse 1.5s ease-in-out infinite;
}

/* F2 yesterday reminder banner */
.f2-yesterday-alert {
  margin-bottom: 0.35rem;
}

.f2-yesterday-alert__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  padding: 0.45rem 0.75rem;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 2px solid #fbbf24;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.15);
}

.f2-yesterday-alert__icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.f2-yesterday-alert__text {
  flex: 1;
  min-width: 12rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.95rem;
  color: #92400e;
}

.f2-yesterday-alert__text strong {
  font-weight: 900;
  color: #b45309;
}

.f2-yesterday-alert__date {
  font-size: 0.8rem;
  font-weight: 700;
  color: #a16207;
}

.f2-yesterday-alert__actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.f2-yesterday-alert__btn {
  min-height: 2.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.65rem;
  font-size: 0.875rem;
  font-weight: 800;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.f2-yesterday-alert__btn--primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.f2-yesterday-alert__btn--primary:hover {
  background: #c00510;
}

.f2-yesterday-alert__btn--ghost {
  background: #fff;
  color: #92400e;
  border-color: #fcd34d;
}

.f2-yesterday-alert__btn--ghost:hover {
  background: #fffbeb;
}

.draft-card {
  display: flex;
  flex-direction: column;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.draft-card:hover {
  border-color: #fecaca;
  box-shadow: 0 8px 24px rgba(227, 6, 19, 0.08);
  transform: translateY(-2px);
}

.draft-card-preview {
  aspect-ratio: 4 / 3;
  background: #f8fafc;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.draft-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.draft-card-pdf {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.draft-card-body {
  padding: 1rem 1.125rem;
}

.draft-card-badge {
  flex-shrink: 0;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  background: #fff1f2;
  color: var(--brand);
  font-size: 0.625rem;
  font-weight: 800;
}

.bill-preview-panel {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: #fafafa;
  margin-bottom: 1rem;
}

.bill-preview-thumb {
  width: 7rem;
  height: 5.25rem;
  border-radius: 0.5rem;
  object-fit: cover;
  object-position: top center;
  border: 1px solid var(--border);
  flex-shrink: 0;
  cursor: zoom-in;
}

.bill-preview-thumb.is-pdf {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e2e8f0;
  font-size: 1.75rem;
}

/* ── Notification bell ── */
.notif-bell-btn {
  position: relative;
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 0.3rem;
  border-radius: 9999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 800;
  line-height: 1.125rem;
  text-align: center;
  box-shadow: 0 2px 6px rgba(227, 6, 19, 0.35);
}

.notif-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  width: min(22rem, calc(100vw - 2rem));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
  z-index: 50;
  overflow: hidden;
}

.notif-dropdown-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fff 0%, #fff9f9 100%);
}

.notif-dropdown-body {
  max-height: 20rem;
  overflow-y: auto;
}

.notif-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.notif-item {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
}

.notif-item.is-unread {
  background: #fff5f5;
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: var(--brand);
  flex-shrink: 0;
  margin-top: 0.35rem;
}

.notif-changes {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.notif-changes li {
  font-size: 0.75rem;
  line-height: 1.35;
}

.notif-product {
  font-weight: 700;
  color: var(--charcoal);
}

.notif-price-change {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.25rem;
  font-weight: 700;
}

.notif-price-change .old {
  color: #9ca3af;
  text-decoration: line-through;
}

.notif-price-change .new {
  color: var(--brand);
}

.sidebar-icon-wrap {
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.sidebar-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  border-radius: 9999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
}

.sidebar-badge-inline {
  margin-left: auto;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  border-radius: 9999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  display: none;
  align-items: center;
  justify-content: center;
}

.sidebar.is-expanded .sidebar-badge-inline,
.sidebar:hover .sidebar-badge-inline {
  display: flex;
}

.sidebar.is-expanded .sidebar-icon-wrap .sidebar-badge,
.sidebar:hover .sidebar-icon-wrap .sidebar-badge {
  display: none;
}

.sidebar-pin {
  opacity: 0;
  transition: opacity 0.2s;
}

.sidebar.is-expanded .sidebar-pin,
.sidebar:hover .sidebar-pin {
  opacity: 1;
}

/* Loader — red + blue */
#globalLoader {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

#globalLoader.show {
  opacity: 1;
  pointer-events: auto;
}

.loader-spinner {
  width: 3.25rem;
  height: 3.25rem;
  border: 4px solid rgba(37, 99, 235, 0.15);
  border-top-color: var(--brand);
  border-right-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* Pagination — purple-red circles */
.cosy-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1rem;
  padding: 1rem 0;
}

.cosy-pagination .pg-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.cosy-pagination .pg-nav {
  color: var(--brand);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  transition: 0.2s;
  background: transparent;
  border: none;
  cursor: pointer;
}

.cosy-pagination .pg-nav:hover:not(:disabled) {
  background: var(--brand-light);
}

.cosy-pagination .pg-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.cosy-pagination .pg-dots {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.cosy-pagination .pg-dot {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  background: #F1F5F9;
  border: none;
  cursor: pointer;
  transition: 0.2s;
}

.cosy-pagination .pg-dot:hover {
  background: #FECACA;
  color: var(--brand);
}

.cosy-pagination .pg-dot.active {
  background: linear-gradient(135deg, var(--pg-purple), var(--brand));
  color: #fff;
  box-shadow: 0 3px 10px rgba(227, 6, 19, 0.35);
}

/* Data tables */
.data-table {
  width: 100%;
  font-size: 0.875rem;
  background: var(--surface);
}

.data-table thead {
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table thead th {
  padding: 0.75rem 1rem;
  font-weight: 700;
  text-align: left;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

.data-table tbody tr:hover {
  background: #FEF2F2;
}

[data-theme="dark"] .data-table tbody tr:hover {
  background: rgba(239, 68, 68, 0.08);
}

.data-table tbody td {
  padding: 0.75rem 1rem;
}

.cost-high {
  color: #991B1B !important;
  font-weight: 800 !important;
}

.cost-ok {
  color: #2563EB;
  font-weight: 600;
}

/* Dashboard animations */
.animate-in {
  animation: fade-scale-in 0.5s ease both;
}

@keyframes fade-scale-in {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.2s; }
.delay-5 { animation-delay: 0.25s; }
.delay-6 { animation-delay: 0.3s; }

/* Stat cards — white + red accent */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 0.9rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

@media (min-width: 640px) {
  .stat-card { padding: 1.25rem; }
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(227, 6, 19, 0.08);
}

.stat-card .stat-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

.stat-card .stat-value {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--brand);
  line-height: 1.1;
  word-break: break-word;
}

@media (min-width: 640px) {
  .stat-card .stat-value { font-size: 1.75rem; }
}

.stat-card .stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.stat-icon-red { background: #FEE2E2; }
.stat-icon-blue { background: #DBEAFE; }
.stat-icon-amber { background: #FEF3C7; }
.stat-icon-green { background: #D1FAE5; }

/* POS */
.pastel-card {
  border-radius: 0.875rem;
  padding: 0.4rem 0.85rem;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  transition: 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 2px solid transparent;
  flex-shrink: 0;
  white-space: nowrap;
  touch-action: manipulation;
}

.pastel-card:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.pastel-card.active {
  border-color: var(--brand);
  box-shadow: 0 4px 16px rgba(227, 6, 19, 0.18);
}

.h-scroll {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.25rem;
}

.h-scroll::-webkit-scrollbar {
  height: 6px;
}

.h-scroll::-webkit-scrollbar-track {
  background: #F1F5F9;
  border-radius: 9999px;
}

.h-scroll::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, var(--pg-purple), var(--brand));
  border-radius: 9999px;
}

/* Product grid — responsive 4×3 (cols × rows flex by breakpoint) */
.product-grid-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.product-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
}

@media (min-width: 640px) {
  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 639px) {
  .product-grid {
    grid-template-rows: repeat(4, minmax(0, 1fr));
  }
}

.product-card {
  cursor: pointer;
  transition: 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 1rem;
  width: 100%;
  min-height: 0;
  height: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  border-color: var(--brand);
  background: #fff;
}

.product-card.added {
  animation: pop-in 0.35s ease;
}

/* Quick Sale Buttons (qsb) — F4 popup 4×4, senior-friendly */
.qsb-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
}

.qsb-panel {
  background: #fff;
  border-radius: 1.25rem;
  width: 100%;
  max-width: 52rem;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  border: 3px solid #fff;
}

.qsb-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 2px solid #f1f5f9;
  flex-shrink: 0;
}

.qsb-title {
  font-size: 1.35rem;
  font-weight: 900;
  color: #111827;
  line-height: 1.2;
}

.qsb-hint {
  font-size: 0.85rem;
  color: #6b7280;
  margin-top: 0.15rem;
}

.qsb-hint kbd {
  font-weight: 800;
  color: var(--brand);
  background: #fef2f2;
  padding: 0.1rem 0.45rem;
  border-radius: 0.35rem;
  font-size: 0.8rem;
}

.qsb-close {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 0.875rem;
  border: 2px solid #e5e7eb;
  background: #fff;
  color: #374151;
  font-size: 1.75rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  line-height: 1;
}

.qsb-close:hover,
.qsb-close:active {
  border-color: var(--brand);
  color: var(--brand);
  background: #fef2f2;
}

.qsb-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: #fafafa;
  border-bottom: 2px solid #f1f5f9;
  flex-shrink: 0;
}

.qsb-mode-tab {
  min-height: 3.25rem;
  padding: 0.65rem 1rem;
  border-radius: 0.875rem;
  border: 2px solid #e5e7eb;
  background: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  color: #374151;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.qsb-mode-tab--use.qsb-mode-tab--active {
  border-color: #e5e7eb;
  background: #fff;
  color: #111827;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.qsb-mode-tab--edit.qsb-mode-tab--active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(227, 6, 19, 0.3);
}

.qsb-grid-slot {
  display: contents;
}

.qsb-empty-hint {
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: #6b7280;
  padding: 0.5rem 0 1rem;
}

.qsb-body {
  padding: 1rem 1.25rem 1.25rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.qsb-grid {
  display: grid;
  /* Mobile: 2 cols (touch-friendly) · sm+: 4 cols (desktop F4 layout) */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

@media (min-width: 640px) {
  .qsb-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
  }
}

.qsb-cell {
  position: relative;
  min-height: 5.75rem;
  border-radius: 1rem;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}

@media (min-width: 640px) {
  .qsb-cell { min-height: 7.5rem; }
}

.qsb-cell--ghost {
  background: #fff;
  border: 2px solid #e5e7eb;
  pointer-events: none;
  min-height: 5.75rem;
}

@media (min-width: 640px) {
  .qsb-cell--ghost { min-height: 7.5rem; }
}

.qsb-cell--edit-filled {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.qsb-cell--sale-inner {
  flex: 1;
  min-height: 0;
  border: none !important;
  box-shadow: none !important;
}

.qsb-cell--sale {
  border: 2px solid #e5e7eb;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
  width: 100%;
}

.qsb-cell--sale:hover,
.qsb-cell--sale:active {
  border-color: #fca5a5;
  box-shadow: 0 6px 20px rgba(227, 6, 19, 0.12);
}

.qsb-cell--sale:active {
  transform: scale(0.97);
}

.qsb-cell--flash {
  animation: qsb-flash 0.4s ease;
}

@keyframes qsb-flash {
  0%, 100% { transform: scale(1); border-color: #e5e7eb; }
  50% { transform: scale(1.03); border-color: var(--brand); box-shadow: 0 0 0 4px rgba(227, 6, 19, 0.2); }
}

.qsb-name {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 0.5rem 0.25rem;
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1.25;
  color: #111827;
  word-break: break-word;
}

@media (min-width: 640px) {
  .qsb-name { font-size: 1.25rem; }
}

.qsb-price {
  padding: 0.4rem 0.5rem 0.75rem;
  font-size: 1.65rem;
  font-weight: 900;
  color: var(--brand);
  line-height: 1;
}

.qsb-cell--empty {
  border: 3px dashed #fca5a5;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  cursor: pointer;
  touch-action: manipulation;
  width: 100%;
}

.qsb-cell--empty:hover,
.qsb-cell--empty:active {
  border-color: var(--brand);
  background: #fef2f2;
  transform: scale(0.98);
}

.qsb-plus {
  font-size: 3rem;
  font-weight: 300;
  color: var(--brand);
  line-height: 1;
}

.qsb-plus-label {
  font-size: 0.85rem;
  font-weight: 800;
  color: #9ca3af;
}

.qsb-cell--empty:hover .qsb-plus-label,
.qsb-cell--empty:active .qsb-plus-label {
  color: var(--brand);
}

.qsb-trash {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: 0.5rem;
  background: #fff;
  color: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  touch-action: manipulation;
}

.qsb-trash svg { width: 1.1rem; height: 1.1rem; }

.qsb-trash:hover,
.qsb-trash:active {
  color: var(--brand);
  background: #fef2f2;
}

.qsb-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.qsb-search-modal {
  background: #fff;
  border-radius: 1.25rem;
  width: 100%;
  max-width: 28rem;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
  border-top: 4px solid var(--brand);
}

.qsb-search-modal-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.qsb-search-modal-title {
  flex: 1;
  font-size: 1.2rem;
  font-weight: 900;
  color: #111827;
}

.qsb-search-modal input[type="search"] {
  width: 100%;
  border: 2px solid #e5e7eb;
  border-radius: 0.875rem;
  padding: 1rem 1.1rem;
  font-size: 1.15rem;
  font-weight: 700;
  min-height: 3.5rem;
  outline: none;
  margin-bottom: 0.75rem;
}

.qsb-search-modal input[type="search"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.12);
}

.qsb-search-results {
  flex: 1;
  min-height: 0;
  max-height: 20rem;
  overflow-y: auto;
  border-radius: 0.75rem;
  border: 2px solid #f3f4f6;
}

.qsb-search-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 1rem 1.1rem;
  border: none;
  border-bottom: 1px solid #f3f4f6;
  background: #fff;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
  min-height: 4rem;
}

.qsb-search-item:last-child { border-bottom: none; }
.qsb-search-item:hover,
.qsb-search-item:active { background: #fef2f2; }

.qsb-search-thumb {
  width: 2.75rem;
  height: 2.75rem;
  object-fit: contain;
  border-radius: 0.5rem;
  background: #f9fafb;
  flex-shrink: 0;
}

.qsb-search-thumb--ph {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.qsb-search-info { flex: 1; min-width: 0; }

.qsb-search-name {
  font-weight: 800;
  font-size: 1rem;
  line-height: 1.3;
  color: #111827;
}

.qsb-search-meta {
  font-size: 0.85rem;
  color: #6b7280;
  margin-top: 0.1rem;
}

.qsb-search-empty {
  padding: 1.5rem;
  text-align: center;
  font-size: 1rem;
  color: #9ca3af;
}

.qsb-foot {
  padding: 0.75rem 1.25rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
  border-top: 2px solid #f1f5f9;
  flex-shrink: 0;
}

/* Daily Cash Record (dcr) — F2 */
.dcr-overlay {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(15, 23, 42, 0.55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
}

.dcr-panel {
  position: relative;
  background: #fff;
  border-radius: 1.25rem;
  width: 100%;
  max-width: 72rem; /* ~ max-w-6xl — 3 คอลัมน์ */
  max-height: 96vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
  border-top: 4px solid var(--brand);
  overflow: hidden;
}

.dcr-saving-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(4px);
}

.dcr-saving-spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.dcr-saving-text {
  font-size: 1rem;
  font-weight: 900;
  color: var(--brand);
}

.dcr-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 2px solid #f1f5f9;
}

.dcr-title {
  font-size: 1.35rem;
  font-weight: 900;
  color: #111827;
}

.dcr-hint {
  font-size: 0.85rem;
  color: #6b7280;
  margin-top: 0.15rem;
}

.dcr-hint kbd {
  font-weight: 800;
  color: var(--brand);
  background: #fef2f2;
  padding: 0.1rem 0.4rem;
  border-radius: 0.3rem;
}

.dcr-close {
  width: 3rem;
  height: 3rem;
  border-radius: 0.75rem;
  border: 2px solid #e5e7eb;
  background: #fff;
  font-size: 1.6rem;
  font-weight: 700;
  color: #374151;
  cursor: pointer;
  flex-shrink: 0;
}

.dcr-close:hover { border-color: var(--brand); color: var(--brand); }

.dcr-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: #fafafa;
  border-bottom: 1px solid #f1f5f9;
}

.dcr-tab {
  min-height: 2.75rem;
  border-radius: 0.75rem;
  border: 2px solid #e5e7eb;
  background: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
}

.dcr-tab--active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.dcr-body {
  padding: 1rem 1.25rem 1.25rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* F2 — 3 คอลัมน์ (ซ้ายเงิน · กลางรายจ่าย · ขวาสรุป) */
.dcr-layout-3 {
  display: grid;
  grid-template-columns: 1.05fr 1.15fr 0.95fr;
  gap: 1rem;
  align-items: start;
  min-height: 0;
}
@media (max-width: 1100px) {
  .dcr-layout-3 {
    grid-template-columns: 1fr 1fr;
  }
  .dcr-col--right {
    grid-column: 1 / -1;
  }
}
@media (max-width: 720px) {
  .dcr-layout-3 {
    grid-template-columns: 1fr;
  }
  .dcr-col--right {
    grid-column: auto;
  }
  .dcr-panel {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 1rem;
  }
}
.dcr-col {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}
.dcr-col--mid .dcr-section--grow {
  flex: 1;
}
.dcr-col--right {
  position: sticky;
  top: 0;
  gap: 0.65rem;
}
.dcr-summary--stack {
  margin: 0;
}
.dcr-summary-title {
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin: 0 0 0.5rem;
  text-align: left;
}
.dcr-actions--stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.15rem;
}
.dcr-actions--stack .dcr-save-btn,
.dcr-actions--stack .dcr-sync-btn {
  width: 100%;
  min-height: 3.35rem;
  font-size: 1.1rem;
}

.dcr-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 520px) {
  .dcr-grid { grid-template-columns: 1fr; }
}

.dcr-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0;
  text-align: left;
}
.dcr-col .dcr-field {
  margin-bottom: 0;
}

.dcr-field--highlight {
  background: #fef2f2;
  border: 2px solid #fecaca;
  border-radius: 1rem;
  padding: 0.85rem;
}

.dcr-pos-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: linear-gradient(135deg, #fef2f2 0%, #fff7ed 100%);
  border: 3px solid #fca5a5;
  border-radius: 1.1rem;
  padding: 1rem 1.15rem;
  margin-bottom: 0.85rem;
}

.dcr-pos-banner__main {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.dcr-pos-banner__label {
  font-size: 1rem;
  font-weight: 900;
  color: #991b1b;
}

.dcr-pos-banner__value {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 900;
  color: var(--brand);
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-align: left;
}

.dcr-pos-banner__hint {
  font-size: 0.8rem;
  font-weight: 700;
  color: #9ca3af;
}

.dcr-pos-banner__refresh {
  flex-shrink: 0;
  min-height: 2.75rem;
  font-size: 0.85rem;
}

.dcr-money-sections {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.dcr-money-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border-radius: 1rem;
  padding: 0.9rem 1rem;
  border: 2px solid transparent;
  text-align: left;
  margin: 0;
}

.dcr-money-card--transfer {
  background: #eff6ff;
  border-color: #93c5fd;
}

.dcr-money-card--cash {
  background: #fef2f2;
  border-color: #fca5a5;
}

.dcr-money-card__label {
  font-size: 1rem;
  font-weight: 900;
  color: #1e3a8a;
}

.dcr-money-card--cash .dcr-money-card__label {
  color: #991b1b;
}

.dcr-money-card__hint {
  font-size: 0.78rem;
  font-weight: 700;
  color: #6b7280;
}

.dcr-income-section {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border: 2px solid #22c55e;
  border-radius: 1rem;
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.75rem;
}

.dcr-input--lg {
  font-size: 1.35rem;
  font-weight: 800;
  min-height: 3.25rem;
  padding: 0.75rem 1rem;
}

.dcr-field--notes {
  margin-top: 0.85rem;
  margin-bottom: 0;
}

.dcr-sublabel--inline {
  font-weight: 700;
  color: #6b7280;
}

.dcr-textarea--lg {
  font-size: 1.1rem;
  font-weight: 700;
  min-height: 4.5rem;
  line-height: 1.5;
}

.dcr-income-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.dcr-income-title {
  font-size: 1.05rem;
  font-weight: 900;
  color: #15803d;
}

.dcr-income-total {
  font-size: 0.95rem;
  font-weight: 800;
  color: #16a34a;
}

.dcr-income-total strong {
  font-size: 1.25rem;
  color: #15803d;
}

.dcr-income-total--lg strong {
  font-size: 1.45rem;
}

.dcr-income-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

@media (max-width: 520px) {
  .dcr-income-grid { grid-template-columns: 1fr; }
}

.dcr-field--income {
  margin-bottom: 0;
}

.dcr-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.1rem 0.4rem;
  border-radius: 0.35rem;
  vertical-align: middle;
  margin-left: 0.25rem;
}

.dcr-tag--cash {
  background: #dcfce7;
  color: #166534;
}

.dcr-tag--transfer {
  background: #dbeafe;
  color: #1d4ed8;
}

.dcr-label {
  font-size: 0.95rem;
  font-weight: 800;
  color: #374151;
  text-align: left;
}

.dcr-sublabel {
  font-size: 0.75rem;
  color: #9ca3af;
  font-weight: 600;
}

.dcr-input {
  width: 100%;
  border: 2px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  font-size: 1.2rem;
  font-weight: 800;
  color: #111827;
  outline: none;
  min-height: 3.25rem;
  text-align: left;
}

.dcr-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.12);
}

.dcr-input::placeholder {
  color: #9ca3af;
  font-weight: 600;
  text-align: left;
  opacity: 1;
}

.dcr-input--xl {
  font-size: 1.55rem;
  text-align: left;
  color: var(--brand);
  font-weight: 900;
}

.dcr-input--lg {
  font-size: 1.2rem;
  text-align: left;
}

.dcr-input--sm {
  font-size: 1rem;
  min-height: 2.75rem;
  text-align: left;
}

.dcr-input--amt {
  max-width: 8.5rem;
  text-align: left;
  flex-shrink: 0;
}

.dcr-select {
  text-align: left;
  text-align-last: left;
}

.dcr-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.dcr-mini-btn {
  min-height: 3.25rem;
  padding: 0 0.85rem;
  border-radius: 0.75rem;
  border: 2px solid #e5e7eb;
  background: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
}

.dcr-mini-btn:hover { border-color: var(--brand); color: var(--brand); }

.dcr-mini-btn--add {
  border-color: #fecaca;
  color: var(--brand);
  background: #fef2f2;
}

.dcr-section {
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  border: 2px solid #f1f5f9;
  border-radius: 1rem;
  background: #fafafa;
}

.dcr-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.dcr-section-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.dcr-mini-btn--active {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}

.dcr-mini-btn--danger {
  border-color: #fecaca;
  color: #b91c1c;
  background: #fef2f2;
}

.dcr-mini-btn--danger:hover {
  border-color: #b91c1c;
  background: #fee2e2;
}

.dcr-manage-types-wrap {
  margin-bottom: 0.65rem;
}

.dcr-manage-types-host {
  min-height: 2rem;
}

.dcr-manage-loading {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.5rem;
}

.dcr-manage-types {
  border: 2px solid #e5e7eb;
  border-radius: 0.85rem;
  background: #fff;
  padding: 0.75rem;
}

.dcr-manage-types-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #f1f5f9;
}

.dcr-manage-types-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--charcoal);
}

.dcr-manage-types-count {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

.dcr-manage-error {
  font-size: 0.85rem;
  font-weight: 700;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 0.5rem;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.5rem;
}

.dcr-type-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
}

.dcr-type-manage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f8fafc;
}

.dcr-type-manage-row:last-child {
  border-bottom: none;
}

.dcr-type-manage-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.dcr-type-manage-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--charcoal);
}

.dcr-type-used-badge {
  font-size: 0.7rem;
  font-weight: 800;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}

.dcr-type-manage-actions {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.dcr-type-edit-form,
.dcr-pin-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  width: 100%;
}

.dcr-type-edit-form .dcr-input,
.dcr-pin-form .dcr-input {
  flex: 1;
  min-width: 8rem;
}

.dcr-pin-panel {
  background: #fff7ed;
  border: 2px solid #fed7aa;
  border-radius: 0.65rem;
  padding: 0.65rem;
  margin-bottom: 0.5rem;
}

.dcr-pin-label {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.dcr-pin-warn {
  font-size: 0.85rem;
  font-weight: 700;
  color: #b45309;
  margin-bottom: 0.5rem;
}

.dcr-type-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.75rem;
}

.dcr-expense-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dcr-expense-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  text-align: left;
}

.dcr-expense-select-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.dcr-select {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  appearance: auto;
}

.dcr-mini-btn--inline {
  flex-shrink: 0;
  min-width: 2.5rem;
  padding: 0.4rem 0.55rem;
}

.dcr-mini-btn--save {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.dcr-add-type-panel {
  margin-bottom: 0.65rem;
  padding: 0.65rem;
  border: 2px dashed #fecaca;
  border-radius: 0.75rem;
  background: #fff;
}

.dcr-add-type-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.dcr-add-type-form .dcr-input {
  flex: 1;
  min-width: 10rem;
}

.dcr-add-row-btn {
  margin-top: 0.5rem;
  width: 100%;
  padding: 0.55rem;
  border: 2px dashed #e5e7eb;
  border-radius: 0.65rem;
  background: transparent;
  color: var(--brand);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.dcr-add-row-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.dcr-remove-btn {
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: 0.5rem;
  background: #fee2e2;
  color: var(--brand);
  font-size: 1.25rem;
  font-weight: 900;
  cursor: pointer;
  flex-shrink: 0;
}

.dcr-textarea {
  width: 100%;
  border: 2px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  resize: vertical;
  min-height: 5rem;
  text-align: left;
}
.dcr-textarea::placeholder {
  color: #9ca3af;
  text-align: left;
}

.dcr-summary {
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
  border: 2px solid #e5e7eb;
  background: #f9fafb;
}

.dcr-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1rem;
  font-weight: 700;
  color: #374151;
  padding: 0.25rem 0;
}

.dcr-summary-row--main {
  font-size: 1.15rem;
  border-top: 1px dashed #e5e7eb;
  margin-top: 0.35rem;
  padding-top: 0.5rem;
}

.dcr-summary-row--var {
  font-size: 1.35rem;
  font-weight: 900;
  margin-top: 0.35rem;
}

.dcr-summary--income {
  border-color: #bbf7d0;
  background: #f0fdf4;
  margin-bottom: 0.5rem;
}

.dcr-amount--income { color: #16a34a; font-weight: 900; }
.dcr-amount--expense { color: #b45309; }
.dcr-amount--profit { color: #166534; font-size: 1.2rem; }

.dcr-summary--ok { border-color: #86efac; background: #f0fdf4; }
.dcr-summary--short { border-color: #fca5a5; background: #fef2f2; }
.dcr-summary--over { border-color: #e5e7eb; background: #f9fafb; }

.dcr-var-status--short {
  color: #dc2626;
  font-weight: 900;
}

.dcr-var-status--over {
  color: #6b7280;
  font-weight: 800;
}

.dcr-var-status--ok {
  color: #15803d;
  font-weight: 800;
}

.dcr-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

@media (max-width: 520px) {
  .dcr-actions { grid-template-columns: 1fr; }
}

.dcr-save-btn {
  width: 100%;
  min-height: 3.75rem;
  border: none;
  border-radius: 1rem;
  background: var(--brand);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(227, 6, 19, 0.28);
  letter-spacing: 0.01em;
}

.dcr-save-btn:disabled { opacity: 0.6; cursor: wait; }

.dcr-sync-btn {
  width: 100%;
  min-height: 3.5rem;
  border: 2px solid #93c5fd;
  border-radius: 1rem;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.dcr-sync-btn:hover:not(:disabled) {
  border-color: #3b82f6;
  background: #dbeafe;
}

.dcr-sync-btn:disabled { opacity: 0.6; cursor: wait; }

.dcr-sync-btn--sm {
  min-height: 2.5rem;
  font-size: 0.9rem;
  width: auto;
  padding: 0 1rem;
}

.dcr-sync-msg {
  font-size: 0.8rem;
  color: #1d4ed8;
  font-weight: 600;
  margin-top: 0.5rem;
  text-align: center;
}

.dcr-history-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed #e5e7eb;
}

.dcr-history-hint {
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 600;
}

.dcr-empty {
  text-align: center;
  color: #9ca3af;
  padding: 2rem;
  font-weight: 600;
}

.dcr-history-card {
  border: 2px solid #e5e7eb;
  border-radius: 0.875rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
  background: #fff;
}

.dcr-history-card--ขาด { border-color: #fca5a5; }
.dcr-history-card--เกิน { border-color: #fcd34d; }
.dcr-history-card--ตรง { border-color: #86efac; }

.dcr-history-date {
  font-weight: 900;
  font-size: 1rem;
  color: #111827;
  margin-bottom: 0.35rem;
}

.dcr-history-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 0.75rem;
  font-size: 0.85rem;
  color: #6b7280;
}

.dcr-history-var {
  margin-top: 0.35rem;
  font-weight: 900;
  font-size: 1rem;
}

.dcr-history-var--ขาด { color: #dc2626; }
.dcr-history-var--เกิน { color: #6b7280; }
.dcr-history-var--ตรง { color: #15803d; }

@keyframes pop-in {
  0% { transform: scale(0.9); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* สรุปออเดอร์ — แถวสินค้า (ชื่อซ้าย · ราคา/จำนวนล่าง · ถังขยะขวา) */
.cart-row {
  display: block;
  text-align: left;
}
.cart-row .cart-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.cart-row .cart-del {
  flex-shrink: 0;
}

.cart-item-enter {
  animation: slide-in-right 0.25s ease-out forwards;
}

@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(1.5rem); }
  to { opacity: 1; transform: translateX(0); }
}

.qty-bump {
  animation: qty-bump 0.35s ease;
}

@keyframes qty-bump {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); color: var(--brand); }
}

/* Bill AI */
.bill-input {
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  padding: 0.45rem 0.65rem;
  width: 100%;
  font-size: 0.875rem;
  outline: none;
  background: var(--surface);
  color: var(--charcoal);
}

.bill-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(227, 6, 19, 0.12);
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 1rem;
  animation: modal-fade-in 0.18s ease-out;
}

.modal-overlay.active { display: flex; }

.modal-panel {
  background: #fff;
  border-radius: 1.25rem;
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(255, 255, 255, 0.08);
  padding: 1.35rem 1.35rem 1.25rem;
  max-height: min(92vh, 720px);
  overflow-y: auto;
  animation: modal-pop-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-pop-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toggle-pack {
  width: 2.5rem;
  height: 1.35rem;
  background: #E5E7EB;
  border-radius: 9999px;
  position: relative;
  cursor: pointer;
  transition: 0.2s;
}

.toggle-pack.on { background: var(--brand); }

.toggle-pack::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1rem;
  height: 1rem;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.toggle-pack.on::after { transform: translateX(1.1rem); }

.row-hidden { display: none !important; }

/* Bill AI product search — pure CSS/JS (no Alpine) so dynamic rows always work */
.product-search-wrap {
  position: relative;
  min-width: 200px;
}

.product-search-input-row {
  position: relative;
  display: flex;
  align-items: center;
}

.product-search-icon {
  position: absolute;
  left: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  pointer-events: none;
  z-index: 1;
  opacity: 0.55;
}

.product-search-input {
  width: 100%;
  padding-left: 1.85rem !important;
  padding-right: 2rem !important;
  min-height: 2.5rem;
  font-size: 0.8rem !important;
  font-weight: 600;
}

.product-search-input.is-linked {
  border-color: #86efac !important;
  background: #f0fdf4;
}

.product-search-clear {
  position: absolute;
  right: 0.3rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  border-radius: 0.45rem;
  background: #fee2e2;
  color: #dc2626;
  font-weight: 800;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  touch-action: manipulation;
}

.product-search-clear:hover {
  background: #fecaca;
}

/* Portal to body — avoids table overflow clipping.
   z-index: 9999 = สูงสุดในแอป (สูงกว่า bottom-nav z-50, #globalLoader z-[60],
   .modal-overlay z-60, .dr-modal-overlay z-55, #toast z-[250])
   เพื่อให้กล่องตัวเลือกสินค้าลอยอยู่ชั้นบนสุดเสมอเมื่อเปิดขึ้นมา
   ไม่ถูก Element อื่นบังหรือบังคับกั้น event นิ้วแตะบนมือถือ */
.product-search-dropdown {
  display: none;
  position: fixed;
  z-index: 9999;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--surface, #fff);
  border: 2px solid var(--border, #e2e8f0);
  border-radius: 0.75rem;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  min-width: 280px;
}

.product-search-dropdown.is-open {
  display: block;
  z-index: 9999;
  pointer-events: auto;
}

.data-table td {
  overflow: visible;
}

.bill-items-table-wrap {
  overflow-x: auto;
  /* allow vertical overflow so absolute fallbacks aren't clipped too hard */
  overflow-y: visible;
}

.product-search-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.45rem;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--charcoal);
  border-bottom: 1px solid var(--border);
  font-family: inherit;
  touch-action: manipulation;
}

.product-search-item:last-of-type { border-bottom: none; }

.product-search-item:hover,
.product-search-item.is-active {
  background: rgba(227, 6, 19, 0.07);
}

/* Optimistic UI — ไฮไลต์ทันทีที่แตะเลือก ไม่ต้องรอผลจากเซิร์ฟเวอร์ */
.product-search-item.is-picked {
  background: rgba(34, 197, 94, 0.18);
  box-shadow: inset 0 0 0 2px rgba(34, 197, 94, 0.35);
}

.product-search-item.is-exact {
  background: rgba(34, 197, 94, 0.1);
}

.product-search-item.is-recent {
  border-left: 3px solid var(--brand);
}

.product-search-alias-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 800;
  color: #1d4ed8;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 0.35rem;
  padding: 0.1rem 0.35rem;
  margin-left: 0.25rem;
  vertical-align: middle;
}

.product-search-item.is-alias {
  border-left: 3px solid #3b82f6;
}

.product-search-recent-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--brand);
  background: rgba(227, 6, 19, 0.08);
  border-radius: 0.35rem;
  padding: 0.1rem 0.35rem;
  margin-left: 0.25rem;
  vertical-align: middle;
}

.product-search-item__name {
  flex: 1 1 100%;
  font-weight: 700;
  line-height: 1.35;
  color: var(--charcoal);
}

.product-search-item__meta {
  color: var(--text-muted, #6B7280);
  font-size: 0.7rem;
  line-height: 1.3;
}

.product-search-item__score {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--brand);
  background: rgba(227, 6, 19, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
}

.product-search-empty-wrap {
  padding: 0.5rem 0.5rem 0.65rem;
}

.product-search-empty {
  padding: 0.65rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted, #9CA3AF);
  text-align: center;
}

.product-search-footer {
  border-top: 1px solid var(--border);
  padding: 0.35rem 0;
  position: sticky;
  bottom: 0;
  background: var(--surface, #fff);
}

.product-search-add-btn {
  display: block;
  width: calc(100% - 1rem);
  margin: 0.35rem 0.5rem 0.5rem;
  padding: 0.6rem;
  min-height: 44px;
  font-size: 0.8rem;
  font-weight: 800;
  color: #fff;
  background: var(--brand, #e30613);
  border: none;
  border-radius: 0.55rem;
  cursor: pointer;
  font-family: inherit;
  touch-action: manipulation;
}

.product-search-add-btn:hover {
  filter: brightness(0.95);
}

.product-link-status {
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 0.3rem;
  line-height: 1.35;
}

.product-link-status.is-linked { color: #15803d; }
.product-link-status.is-unlinked { color: #9CA3AF; }

.bill-name-input {
  font-weight: 700 !important;
  font-size: 0.85rem !important;
  min-height: 2.35rem;
}

.bill-row-delete {
  width: 2.5rem;
  height: 2.5rem;
  min-width: 44px;
  min-height: 44px;
  border-radius: 0.65rem;
  background: #fef2f2;
  color: #dc2626;
  font-weight: 800;
  font-size: 1.15rem;
  border: 1px solid #fecaca;
  cursor: pointer;
  touch-action: manipulation;
  line-height: 1;
}

.bill-row-delete:hover {
  background: #fee2e2;
}

.bill-cost-value {
  display: block;
  font-weight: 800;
  font-size: 0.875rem;
}

.bill-cost-hint,
.bill-price-hint {
  font-size: 0.6rem;
  color: var(--text-muted, #9CA3AF);
  margin-top: 0.15rem;
}

.bill-price-input {
  font-weight: 700;
}

.bill-cost-row {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.bill-cost-old,
.bill-price-old {
  color: #6B7280;
  font-size: 0.7rem;
  font-weight: 600;
  text-decoration: line-through;
  opacity: 0.85;
}

.bill-price-old {
  text-decoration: none;
  margin-top: 0.15rem;
}

.bill-suggest-btn {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--brand);
  background: rgba(227, 6, 19, 0.06);
  border: 1px solid rgba(227, 6, 19, 0.25);
  border-radius: 0.45rem;
  padding: 0.3rem 0.4rem;
  cursor: pointer;
}

.bill-suggest-btn:hover {
  background: rgba(227, 6, 19, 0.12);
}

.bill-cost-input {
  font-weight: 700;
}

.bill-blocker-btn {
  display: inline;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.bill-blocker-btn:hover {
  color: #991B1B;
}

.bill-blocker-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border, #E5E7EB);
  background: #FAFAFA;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.bill-blocker-item:hover {
  background: #FEF2F2;
  border-color: rgba(227, 6, 19, 0.25);
}

.data-table tbody tr.row-loss {
  background: rgba(254, 242, 242, 0.55);
}

.data-table tbody tr.row-unlinked {
  background: rgba(255, 251, 235, 0.45);
}

.data-table tbody tr.row-blocker-flash {
  animation: bill-row-flash 2.5s ease;
}

@keyframes bill-row-flash {
  0%, 100% { box-shadow: inset 0 0 0 0 transparent; }
  15%, 45% { box-shadow: inset 3px 0 0 var(--brand, #E30613); }
}

.upload-zone {
  border: 2px dashed rgba(227, 6, 19, 0.35);
  transition: 0.2s;
}

.upload-zone:hover {
  border-color: var(--brand);
  background: rgba(227, 6, 19, 0.03);
}

.upload-zone.is-dragover {
  border-color: var(--brand);
  background: rgba(227, 6, 19, 0.08);
  box-shadow: 0 0 0 4px rgba(227, 6, 19, 0.12);
}

.upload-zone.is-dragover .upload-zone-icon {
  transform: scale(1.08);
  transition: transform 0.15s;
}

/* Navbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* Inventory product list */
.th-sort {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 0.15s;
}

.th-sort:hover {
  color: var(--brand);
}

.th-sort .sort-icon {
  display: inline-block;
  margin-left: 0.2rem;
  font-size: 0.65rem;
  opacity: 0.45;
}

.th-sort.active .sort-icon {
  opacity: 1;
  color: var(--brand);
}

.inv-row-enter {
  animation: inv-row-in 0.35s ease both;
}

@keyframes inv-row-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.import-drop {
  border: 2px dashed rgba(227, 6, 19, 0.3);
  transition: border-color 0.2s, background 0.2s;
}

.import-drop:hover,
.import-drop.dragover {
  border-color: var(--brand);
  background: rgba(227, 6, 19, 0.03);
}

.stock-low {
  color: var(--brand);
  font-weight: 800;
}

.import-success-flash {
  animation: import-flash 1.2s ease;
}

@keyframes import-flash {
  0%, 100% { box-shadow: none; }
  30% { box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.25); }
}

/* ── Toast "พบสินค้าใหม่" — นับถอยหลัง 15 วิ (หน้าขาย) ── */
.unknown-toast {
  animation: uq-toast-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.unknown-toast--out {
  animation: uq-toast-out 0.2s ease-in both;
  pointer-events: none;
}

@keyframes uq-toast-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes uq-toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(10px) scale(0.96); }
}

/* หยุดนับถอยหลังตอน hover/focus — bar เบลอจางลงบอกสถานะ pause */
.unknown-toast.is-paused .unknown-toast__bar {
  opacity: 0.5;
}

.unknown-toast__secs {
  min-width: 1.6rem;
  text-align: right;
}

@media (prefers-reduced-motion: reduce) {
  .unknown-toast,
  .unknown-toast--out {
    animation: none !important;
  }
}

/* Mobile sidebar overlay */
@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    height: 100vh;
    transform: translateX(-100%);
    width: var(--sidebar-expanded) !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar.mobile-open .sidebar-brand-text,
  .sidebar.mobile-open .sidebar-link-text,
  .sidebar.mobile-open .sidebar-footer-text,
  .sidebar.mobile-open .sidebar-badge-inline {
    opacity: 1;
    width: auto;
    display: flex;
  }

  .sidebar.mobile-open .sidebar-sublink {
    display: flex;
  }

  .sidebar.mobile-open .sidebar-icon-wrap .sidebar-badge {
    display: none;
  }
}

/* ── Sale Success Modal (ขายสำเร็จ + เงินทอน) ── */
.ssm-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.ssm-overlay--open {
  display: flex !important;
}

.ssm-panel {
  position: relative;
  width: 100%;
  max-width: 22rem;
  background: var(--surface);
  border-radius: 1.25rem;
  padding: 2rem 1.75rem 0;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  border: 2px solid var(--brand-light);
  overflow: hidden;
}

.ssm-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.ssm-close:hover {
  background: var(--brand-light);
  color: var(--brand);
}

.ssm-icon {
  width: 4.5rem;
  height: 4.5rem;
  margin: 0 auto 1rem;
  background: #D1FAE5;
  border-radius: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ssm-title {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--charcoal);
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.ssm-codename {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.ssm-change-box {
  background: #ECFDF5;
  border: 2px solid #A7F3D0;
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  margin: 0.75rem 0 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.ssm-change-label {
  display: block;
  font-size: 1.125rem;
  font-weight: 800;
  color: #047857;
  line-height: 1.3;
}

.ssm-change-amount {
  display: block;
  font-size: 2.75rem;
  font-weight: 900;
  color: #059669;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.ssm-change-unit {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
  color: #047857;
  line-height: 1.3;
}

.ssm-hint {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.ssm-progress-track {
  height: 5px;
  background: #F1F5F9;
  margin: 0 -1.75rem;
  overflow: hidden;
}

.ssm-progress-bar {
  height: 100%;
  background: var(--brand);
  transition: width 0.05s linear;
  border-radius: 0 2px 2px 0;
}

/* ── Settings toggle ── */
.settings-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.settings-toggle__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.settings-toggle__track {
  position: relative;
  width: 3rem;
  height: 1.65rem;
  border-radius: 9999px;
  background: #d1d5db;
  transition: background 0.2s;
  flex-shrink: 0;
}

.settings-toggle__track::after {
  content: '';
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.settings-toggle__input:checked + .settings-toggle__track {
  background: #22c55e;
}

.settings-toggle__input:checked + .settings-toggle__track::after {
  transform: translateX(1.35rem);
}

.settings-toggle__label {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--charcoal);
}

/* ── Settings page duration buttons ── */
.settings-duration-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 1.25rem 0.5rem;
  border-radius: 1rem;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--charcoal);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  min-height: 5rem;
}

.settings-duration-btn:hover {
  border-color: var(--brand);
  background: var(--brand-light);
}

.settings-duration-btn--active {
  border-color: var(--brand);
  background: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.15);
}

.settings-danger-check {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #991b1b;
}

.settings-pin-input {
  width: 100%;
  border: 2px solid #fecaca;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  outline: none;
}

.settings-pin-input:focus {
  border-color: #dc2626;
}

.settings-clear-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}

@media (max-width: 560px) {
  .settings-clear-grid { grid-template-columns: 1fr; }
}

.settings-clear-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1rem 0.65rem;
  border-radius: 1rem;
  border: 2px solid #fecaca;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  text-align: center;
}

.settings-clear-btn:hover {
  border-color: #dc2626;
  background: #fef2f2;
  transform: translateY(-1px);
}

.settings-clear-btn__icon {
  font-size: 1.75rem;
  line-height: 1;
}

.settings-clear-btn__title {
  font-size: 0.95rem;
  font-weight: 900;
  color: #991b1b;
}

.settings-clear-btn__desc {
  font-size: 0.72rem;
  font-weight: 600;
  color: #9ca3af;
}

.settings-clear-modal {
  background: #fff;
  border-radius: 1.25rem;
  padding: 1.5rem;
  max-width: 24rem;
  width: 100%;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
  border-top: 4px solid #dc2626;
}

/* Pay modal — live change preview */
.pay-change-preview {
  text-align: center;
  padding: 0.65rem 1rem;
  border-radius: 0.75rem;
  font-weight: 800;
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  transition: opacity 0.15s;
}

.pay-change-preview--visible {
  background: #ECFDF5;
  color: #047857;
  border: 2px solid #A7F3D0;
}

.pay-change-preview--hidden {
  opacity: 0;
  height: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  border: none;
}

/* ── Thai Date Picker ── */
.thai-dp-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--charcoal);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(227, 6, 19, 0.04);
  max-width: 100%;
}

.thai-dp-trigger:hover {
  border-color: var(--brand);
  box-shadow: 0 4px 16px rgba(227, 6, 19, 0.1);
}

.thai-dp-trigger-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.65rem;
  background: var(--brand-light);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.thai-dp-trigger-text {
  flex: 1;
  min-width: 0;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thai-dp-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12), 0 4px 16px rgba(227, 6, 19, 0.06);
  overflow: hidden;
  width: min(100vw - 2rem, 42rem);
}

.thai-dp-layout {
  display: flex;
  flex-direction: column;
}

@media (min-width: 640px) {
  .thai-dp-layout {
    flex-direction: row;
  }
}

.thai-dp-presets {
  padding: 1rem;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex-shrink: 0;
}

@media (min-width: 640px) {
  .thai-dp-presets {
    flex-direction: column;
    flex-wrap: nowrap;
    width: 9.5rem;
    border-bottom: none;
    border-right: 1px solid var(--border);
    gap: 0.25rem;
  }
}

.thai-dp-presets-title {
  width: 100%;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

@media (min-width: 640px) {
  .thai-dp-presets-title {
    margin-bottom: 0.5rem;
  }
}

.thai-dp-preset {
  padding: 0.45rem 0.75rem;
  border-radius: 0.65rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--charcoal);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.thai-dp-preset:hover {
  background: var(--brand-light);
  color: var(--brand);
}

.thai-dp-preset.is-active {
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.thai-dp-calendar {
  flex: 1;
  padding: 1rem;
  min-width: 0;
}

.thai-dp-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.thai-dp-nav-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--charcoal);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.thai-dp-nav-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}

.thai-dp-selectors {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  justify-content: center;
}

.thai-dp-selector {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.65rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--charcoal);
  cursor: pointer;
  transition: all 0.15s ease;
}

.thai-dp-selector:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.thai-dp-dropdown {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  padding: 0.35rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.15rem;
  min-width: 14rem;
  max-height: 12rem;
  overflow-y: auto;
}

.thai-dp-dropdown-years {
  grid-template-columns: repeat(2, 1fr);
  min-width: 8rem;
}

.thai-dp-dropdown-item {
  padding: 0.4rem 0.5rem;
  border-radius: 0.45rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--charcoal);
  cursor: pointer;
  text-align: center;
  transition: all 0.12s ease;
}

.thai-dp-dropdown-item:hover {
  background: var(--brand-light);
  color: var(--brand);
}

.thai-dp-dropdown-item.is-active {
  background: var(--brand);
  color: #fff;
}

.thai-dp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.15rem;
  margin-bottom: 0.35rem;
}

.thai-dp-weekday {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  padding: 0.25rem 0;
}

.thai-dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.15rem;
}

.thai-dp-day {
  aspect-ratio: 1;
  min-height: 2.25rem;
  border: none;
  border-radius: 0.5rem;
  background: transparent;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--charcoal);
  cursor: pointer;
  transition: all 0.12s ease;
  position: relative;
}

.thai-dp-day:hover:not(.is-out) {
  background: var(--brand-light);
  color: var(--brand);
}

.thai-dp-day.is-out {
  color: var(--text-muted);
  opacity: 0.35;
  cursor: default;
}

.thai-dp-day.is-today:not(.is-selected) {
  font-weight: 800;
  color: var(--brand);
  box-shadow: inset 0 0 0 1.5px var(--brand);
}

.thai-dp-day.is-in-range {
  background: rgba(227, 6, 19, 0.08);
  border-radius: 0;
}

.thai-dp-day.is-range-start {
  background: var(--brand);
  color: #fff;
  border-radius: 0.5rem 0 0 0.5rem;
  font-weight: 800;
}

.thai-dp-day.is-range-end {
  background: var(--brand);
  color: #fff;
  border-radius: 0 0.5rem 0.5rem 0;
  font-weight: 800;
}

.thai-dp-day.is-selected.is-range-start.is-range-end {
  border-radius: 0.5rem;
}

.thai-dp-footer {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.thai-dp-footer-label {
  font-size: 0.8125rem;
  min-width: 0;
}

.thai-dp-footer-label strong {
  color: var(--charcoal);
  font-weight: 800;
}

.thai-dp-footer-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.thai-dp-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 800;
  background: var(--brand-light);
  color: var(--brand);
  min-width: 0;
  height: auto;
}

[data-theme="dark"] .thai-dp-panel {
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .thai-dp-day.is-in-range {
  background: rgba(239, 68, 68, 0.15);
}
/* -- Daily Records Viewer (mobile-first) -- */
.dr-page { padding-bottom: 2rem; }

.dr-field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.dr-label { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); }
.dr-input {
  width: 100%;
  min-height: 48px;
  padding: 0.65rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: 0.85rem;
  background: var(--surface);
  color: var(--charcoal);
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  transition: border-color 0.15s ease;
}
.dr-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.12);
}
.dr-input--lg { min-height: 56px; font-size: 1.25rem; font-weight: 800; }
.dr-textarea { min-height: 5.5rem; resize: vertical; line-height: 1.45; font-weight: 500; }

.dr-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
@media (min-width: 640px) {
  .dr-summary { grid-template-columns: repeat(4, 1fr); }
}
.dr-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.75rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.dr-chip-label { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.dr-chip-val { font-size: 1.15rem; font-weight: 900; color: var(--charcoal); }
.dr-chip--in .dr-chip-val { color: #059669; }
.dr-chip--out .dr-chip-val { color: #DC2626; }

.dr-table tbody td { padding: 1rem; vertical-align: middle; }
.dr-row { cursor: pointer; }
.dr-row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.dr-var--short { color: #DC2626; }
.dr-var--over { color: #2563EB; }
.dr-var--ok { color: #059669; }

.dr-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.25rem;
  padding: 0.3rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 800;
}
.dr-status--short { background: #FEE2E2; color: #B91C1C; }
.dr-status--over { background: #DBEAFE; color: #1D4ED8; }
.dr-status--ok { background: #D1FAE5; color: #047857; }
[data-theme="dark"] .dr-status--short { background: rgba(185, 28, 28, 0.25); color: #FCA5A5; }
[data-theme="dark"] .dr-status--over { background: rgba(37, 99, 235, 0.25); color: #93C5FD; }
[data-theme="dark"] .dr-status--ok { background: rgba(4, 120, 87, 0.25); color: #6EE7B7; }

.dr-card {
  display: block;
  padding: 1rem 1.1rem;
  border-radius: 1.1rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.dr-card:active { transform: scale(0.985); }
.dr-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 0.75rem;
}
.dr-card-k { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.dr-card-v { font-size: 1.15rem; font-weight: 900; line-height: 1.2; margin-top: 0.1rem; }

.dr-modal-overlay {
  align-items: flex-end;
  padding: 0;
  z-index: 55;
}
@media (min-width: 640px) {
  .dr-modal-overlay {
    align-items: center;
    padding: 1rem;
  }
}
.dr-modal {
  width: 100%;
  max-width: 28rem;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 1.25rem 1.25rem 0 0;
  padding: 1.15rem 1.15rem 1.5rem;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.12);
}
@media (min-width: 640px) {
  .dr-modal {
    border-radius: 1.25rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
  }
}
.dr-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.dr-modal-close {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.85rem;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--charcoal);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.dr-modal-close:hover { border-color: var(--brand); color: var(--brand); }
.dr-modal-snapshot {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding: 0.85rem;
  border-radius: 1rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}
.dr-modal-form { display: flex; flex-direction: column; gap: 0.9rem; }
.dr-modal-actions { display: flex; gap: 0.65rem; margin-top: 0.35rem; }
.dr-error {
  background: #FEE2E2;
  color: #B91C1C;
  border: 1px solid #FECACA;
  border-radius: 0.75rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

/* Network status pill (topbar) */
.net-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.25rem;
  padding: 0.25rem 0.65rem 0.25rem 0.5rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--charcoal);
  white-space: nowrap;
  user-select: none;
}
.net-status-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 9999px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.04);
}
.net-status-dot--green {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}
.net-status-dot--yellow {
  background: #eab308;
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.28);
}
.net-status-dot--gray {
  background: #9ca3af;
  box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.25);
}
.net-status-label { line-height: 1; }
/* ป้ายจำนวนบิลที่รอซิงค์ขึ้น VPS (อยู่ใน pill สถานะ) */
.net-status-queue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 9999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.22);
}
.net-status-queue.hidden { display: none; }
@media (max-width: 380px) {
  .net-status-label { display: none; }
  .net-status-pill { padding: 0.35rem; min-width: 2rem; justify-content: center; }
}

/* ═══════════════════════════════════════════════════════════
   Mobile Support — Bottom Nav + touch-friendly (Desktop intact)
   Breakpoint: lg = 1024px  (same as sidebar mobile drawer)
   ═══════════════════════════════════════════════════════════ */
:root {
  --bottom-nav-h: 4.25rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Bottom Navigation — mobile only (hidden on lg+ via Tailwind lg:hidden) */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  min-height: var(--bottom-nav-h);
  padding: 0.25rem 0.15rem calc(0.35rem + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
  -webkit-tap-highlight-color: transparent;
}

[data-theme="dark"] .bottom-nav {
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 44px;
  min-width: 0;
  padding: 0.35rem 0.15rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.15;
  text-decoration: none;
  cursor: pointer;
  border-radius: 0.75rem;
  touch-action: manipulation;
  transition: color 0.15s ease, background 0.15s ease;
}

.bottom-nav__item:active {
  background: var(--brand-light);
}

.bottom-nav__item--active {
  color: var(--brand);
}

.bottom-nav__item--active .bottom-nav__icon {
  color: var(--brand);
}

.bottom-nav__icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  color: inherit;
}

.bottom-nav__icon svg {
  width: 1.35rem;
  height: 1.35rem;
}

.bottom-nav__label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.bottom-nav__badge {
  position: absolute;
  top: -0.2rem;
  right: -0.45rem;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.25rem;
  border-radius: 9999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Main content clears bottom nav on mobile */
@media (max-width: 1023px) {
  .app-main {
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 1rem) !important;
  }

  /* Sidebar drawer: full expanded labels when open */
  .sidebar.mobile-open {
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
  }

  /* Touch targets */
  .sidebar-link {
    min-height: 3rem;
    padding: 0.85rem 0.85rem;
    font-size: 0.95rem;
  }

  /* Readable base on small screens */
  html {
    -webkit-text-size-adjust: 100%;
  }

  /* Hide desktop keyboard shortcut chrome on phones */
  .desktop-only-hint {
    display: none !important;
  }

  /* Toast: bottom left corner */
  #toast {
    top: auto !important;
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 0.75rem) !important;
    left: 0.75rem !important;
    right: auto !important;
    max-width: calc(100vw - 1.5rem);
  }

  /* F4 Quick Sale — bottom sheet on phone */
  .qsb-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .qsb-panel {
    max-width: 100%;
    max-height: 96vh;
    border-radius: 1.25rem 1.25rem 0 0;
  }
  .qsb-name { font-size: 1rem; padding: 0.55rem 0.4rem 0.2rem; }
  .qsb-price { font-size: 1.35rem; }
  .qsb-hint kbd { display: none; }

  /* F2 Daily Cash — full-screen sheet on phone */
  .dcr-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .dcr-panel {
    max-width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 1.15rem 1.15rem 0 0;
  }
  .dcr-title { font-size: 1.1rem; }
  .dcr-hint kbd { display: none; }
  .dcr-header { padding: 0.85rem 1rem; }
  .dcr-body { padding: 0.85rem 1rem 1.25rem; }
  .dcr-tabs { padding: 0.65rem 1rem; }
  .dcr-tab { min-height: 3rem; font-size: 0.95rem; }
  .dcr-input--lg,
  .dcr-input--xl {
    min-height: 3.25rem;
    font-size: 1.15rem;
  }
  .dcr-actions--stack .dcr-save-btn,
  .dcr-actions--stack .dcr-sync-btn {
    min-height: 3.5rem;
  }

  /* POS page mobile */
  .pos-layout {
    gap: 0.75rem;
  }
  .pos-toolbar {
    flex-wrap: wrap;
  }
  .pos-toolbar__scan {
    flex: 1 1 100%;
    min-width: 0;
  }
  .pos-toolbar__actions {
    display: flex;
    gap: 0.5rem;
    width: 100%;
  }
  .pos-toolbar__actions .btn {
    flex: 1;
    min-height: 48px;
    font-size: 0.9rem;
  }
  #searchInput {
    font-size: 1rem !important;
    padding-top: 0.9rem !important;
    padding-bottom: 0.9rem !important;
  }
  #scanInputWrap.is-listening::after {
    font-size: 0.65rem;
    right: 0.6rem;
    padding: 0.15rem 0.4rem;
  }
  .pos-cart {
    border-radius: 1rem;
  }
  .pos-cart #cartList {
    max-height: 36vh;
  }
  .pos-cart .btn-primary {
    min-height: 52px;
    font-size: 1.1rem;
  }

  /* Pay modal — larger numpad on mobile */
  #payModal .bg-white {
    max-height: 96vh;
    overflow-y: auto;
    padding: 1.15rem !important;
  }
  #payModal #cashDisplay {
    font-size: 2.75rem !important;
    margin: 0.75rem 0 !important;
  }
  #numpad button {
    min-height: 3.25rem !important;
    font-size: 1.25rem !important;
  }
  #payShortcutHint {
    display: none !important;
  }

  /* Product cards — comfortable tap */
  .product-card {
    min-height: 5.5rem;
  }

  /* Bill AI upload zone */
  .upload-zone {
    min-height: 200px !important;
    padding: 1.5rem 1rem !important;
  }
  .upload-zone h2 {
    font-size: 1.1rem !important;
  }

  /* Tables: ensure horizontal scroll feels native */
  .data-table {
    font-size: 0.875rem;
  }

  /* Pagination compact */
  .cosy-pagination {
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: center;
  }
  .cosy-pagination .pg-info {
    width: 100%;
    text-align: center;
  }
}

/* Tablet portrait: F4 centered panel (not bottom sheet) */
@media (min-width: 640px) and (max-width: 1023px) {
  .qsb-overlay {
    padding: 0.75rem;
    align-items: center;
  }
  .qsb-panel {
    border-radius: 1.25rem;
    max-width: 52rem;
  }
}

/* Desktop (lg+): ensure bottom-nav never steals layout */
@media (min-width: 1024px) {
  .bottom-nav {
    display: none !important;
  }
  .app-main {
    padding-bottom: inherit;
  }
}

/* Utility: touch manipulation for interactive chrome */
.touch-manipulation {
  touch-action: manipulation;
}
