/* ─── RESET & BASE ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Font scale — changed by JS (1 = normal, 1.15 = large, 1.3 = xl) */
  --fs: 1;

  /* Dark theme (default) */
  --bg:          #0f1117;
  --bg-panel:    #1a1d27;
  --bg-card:     #22263a;
  --bg-input:    #2a2f45;
  --bg-hover:    #2f3550;
  --bg-selected: #1e3a5f;
  --bg-header:   #111420;
  --border:      #2e3348;
  --border-light:#3a3f5c;

  --text:        #f0f2f8;
  --text-muted:  #c0cade;
  --text-dim:    #8c9ab8;

  --accent:      #3b82f6;
  --accent-dark: #2563eb;
  --green:       #22c55e;
  --green-dark:  #16a34a;
  --red:         #f28c28;
  --red-dark:    #d4750a;
  --amber:       #f59e0b;

  --radius:      6px;
  --radius-lg:   10px;
  --shadow:      0 4px 16px rgba(0,0,0,0.4);

  --header-h:    58px;
  --footer-h:    66px;
  --tab-h:       52px;
}

/* ─── LIGHT MODE ─── */
body.light {
  --bg:          #f0f2f8;
  --bg-panel:    #ffffff;
  --bg-card:     #f5f7fd;
  --bg-input:    #e8ecf8;
  --bg-hover:    #dde3f5;
  --bg-selected: #dbeafe;
  --bg-header:   #ffffff;
  --border:      #d0d5e8;
  --border-light:#bcc4de;

  --text:        #111827;
  --text-muted:  #374151;
  --text-dim:    #6b7280;

  --accent:      #2563eb;
  --accent-dark: #1d4ed8;
  --green:       #16a34a;
  --green-dark:  #15803d;
  --red:         #e07818;
  --red-dark:    #c4650e;
  --amber:       #b45309;

  --shadow:      0 4px 16px rgba(0,0,0,0.12);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: calc(16px * var(--fs));
  background: var(--bg);
  color: var(--text);
}

#app {
  display: grid;
  grid-template-rows: var(--header-h) 1fr var(--footer-h);
  height: 100vh;
  overflow: hidden;
}

/* ─── HEADER ─── */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-header);
  border-bottom: 2px solid var(--border);
  padding: 0 14px;
  gap: 10px;
  user-select: none;
  flex-shrink: 0;
}

body.light #top-bar { box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-img {
  height: 28px;
  width: auto;
  display: block;
  /* Dark mode: white pill so original dark text + orange diamond read correctly */
  background: rgba(255,255,255,0.93);
  padding: 4px 10px;
  border-radius: 5px;
}

body.light .logo-img {
  /* Light mode: no background needed, logo reads naturally on white header */
  background: none;
  padding: 0;
  border-radius: 0;
}

.header-left .divider { color: var(--border-light); }

.cashier-info, .order-info {
  font-size: calc(15px * var(--fs));
  color: var(--text-muted);
  white-space: nowrap;
}

.cashier-info strong, .order-info strong { color: var(--text); }

.header-shortcuts {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  font-size: calc(13px * var(--fs));
  color: var(--text-muted);
}

.header-shortcuts span { white-space: nowrap; }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#clock {
  font-size: calc(16px * var(--fs));
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Consolas', monospace;
  white-space: nowrap;
}

/* ─── ACCESSIBILITY CONTROLS ─── */
.a11y-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px 8px;
}

.font-size-controls {
  display: flex;
  align-items: center;
  gap: 3px;
}

.btn-a11y {
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.font-btn {
  font-weight: 700;
  font-size: 13px;
  width: 26px;
  height: 26px;
  font-family: inherit;
}

.font-btn-lg { font-size: 16px; width: 28px; height: 28px; }
.font-btn-xl { font-size: 19px; width: 30px; height: 30px; }

.font-btn:hover, .theme-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-light);
}

.font-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.theme-btn {
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-left: 1px solid var(--border);
  border-radius: 0 5px 5px 0;
  margin-left: 3px;
  padding-left: 6px;
}

/* ─── KBD KEYS ─── */
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 22px;
  padding: 0 5px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-bottom-width: 2px;
  border-radius: 3px;
  font-size: calc(12px * var(--fs));
  font-family: 'SF Mono', 'Consolas', monospace;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1;
}

/* ─── MAIN LAYOUT ─── */
#main {
  display: grid;
  grid-template-columns: 1fr 460px;
  overflow: hidden;
}

/* ─── ORDER PANEL (LEFT) ─── */
#order-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg-panel);
  border-right: 2px solid var(--border);
  overflow: hidden;
}

/* Customer bar */
#customer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  gap: 10px;
  flex-shrink: 0;
}

.customer-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.customer-icon { font-size: calc(18px * var(--fs)); }

.customer-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#customer-name-display {
  font-size: calc(16px * var(--fs));
  font-weight: 600;
  color: var(--text);
}

.customer-sub {
  font-size: calc(13px * var(--fs));
  color: var(--text-muted);
}

.customer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

#btn-clear-customer { display: none; }

/* Order items area */
#order-items-wrap {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#order-items-header {
  display: grid;
  grid-template-columns: 54px 1fr 76px 88px 38px;
  padding: 8px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: calc(13px * var(--fs));
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

body.light #order-items-header { background: var(--bg-card); }

#order-items {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

#order-items::-webkit-scrollbar { width: 7px; }
#order-items::-webkit-scrollbar-track { background: transparent; }
#order-items::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

/* Empty order state */
#empty-order {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px 20px;
  color: var(--text-dim);
  text-align: center;
  gap: 8px;
}

.empty-icon { font-size: 48px; margin-bottom: 8px; }
#empty-order p { font-size: calc(15px * var(--fs)); }
#empty-order .hint { font-size: calc(13px * var(--fs)); color: var(--text-dim); }

/* Order line item */
.order-item {
  display: grid;
  grid-template-columns: 54px 1fr 76px 88px 38px;
  align-items: center;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  gap: 4px;
}

.order-item:hover { background: var(--bg-hover); }
.order-item.selected {
  background: var(--bg-selected);
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}

.item-qty {
  font-size: calc(17px * var(--fs));
  font-weight: 700;
  color: var(--accent);
  text-align: center;
}

.item-name-wrap { overflow: hidden; }

.item-name {
  font-size: calc(15px * var(--fs));
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-sku {
  font-size: calc(12px * var(--fs));
  color: var(--text-dim);
  font-family: monospace;
}

.item-unit-price {
  font-size: calc(14px * var(--fs));
  color: var(--text-muted);
  text-align: right;
}

.item-total {
  font-size: calc(15px * var(--fs));
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

.item-del-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: calc(18px * var(--fs));
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
}

.item-del-btn:hover { background: var(--red); color: white; }

/* Order totals */
#order-totals {
  background: var(--bg-card);
  border-top: 2px solid var(--border);
  padding: 10px 14px 8px;
  flex-shrink: 0;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: calc(15px * var(--fs));
  color: var(--text-muted);
}

.total-final {
  font-size: calc(28px * var(--fs));
  font-weight: 800;
  color: var(--text);
  padding: 6px 0 4px;
  border-top: 2px solid var(--border-light);
  margin-top: 4px;
}

.amount-discount { color: var(--green); }

.total-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 5px;
  font-size: calc(13px * var(--fs));
  color: var(--text-dim);
}

.order-note-badge {
  font-size: calc(13px * var(--fs));
  color: var(--amber);
}

/* ─── ACTION PANEL (RIGHT) ─── */
#action-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

/* Tabs */
#tab-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: var(--bg-card);
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}

.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: var(--tab-h);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  font-size: calc(15px * var(--fs));
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0 8px;
}

.tab:hover { background: var(--bg-hover); color: var(--text); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--bg-panel);
}

.tab-key {
  font-size: calc(11px * var(--fs));
  font-weight: 700;
  padding: 2px 5px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  color: var(--text-dim);
  font-family: monospace;
}

/* Tab content */
.tab-content {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.tab-content.active { display: flex; }

/* Search input */
.search-row {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}

.search-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.search-icon {
  padding: 0 8px 0 10px;
  color: var(--text-dim);
  font-size: 20px;
  font-weight: 300;
}

.search-input-wrap input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: calc(16px * var(--fs));
  padding: 12px 4px;
  caret-color: var(--accent);
}

.search-input-wrap input::placeholder { color: var(--text-dim); }

.btn-clear-input {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 0 10px;
  cursor: pointer;
  font-size: calc(15px * var(--fs));
  height: 100%;
  transition: color 0.1s;
}

.btn-clear-input:hover { color: var(--red); }

/* Search results */
#search-results-wrap, #customer-results-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

#search-results-wrap::-webkit-scrollbar,
#customer-results-wrap::-webkit-scrollbar { width: 7px; }
#search-results-wrap::-webkit-scrollbar-thumb,
#customer-results-wrap::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

.search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  gap: 10px;
}

.search-result:hover { background: var(--bg-hover); }
.search-result.focused { background: var(--bg-selected); }

.result-info { overflow: hidden; }

.result-name {
  font-size: calc(16px * var(--fs));
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-meta {
  font-size: calc(13px * var(--fs));
  color: var(--text-muted);
  margin-top: 2px;
}

.result-price {
  font-size: calc(17px * var(--fs));
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
  flex-shrink: 0;
}

.result-btns {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.result-add-btn,
.result-info-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  flex-shrink: 0;
}

.result-add-btn  { font-size: calc(20px * var(--fs)); }
.result-info-btn { font-size: calc(15px * var(--fs)); font-weight: 700; font-style: italic; font-family: Georgia, serif; }

.result-add-btn:hover, .search-result.focused .result-add-btn {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.result-info-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Customer result */
.customer-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  gap: 10px;
}

.customer-result:hover { background: var(--bg-hover); }
.customer-result.focused { background: var(--bg-selected); }

.cust-name {
  font-size: calc(16px * var(--fs));
  font-weight: 600;
  color: var(--text);
}

.cust-meta {
  font-size: calc(13px * var(--fs));
  color: var(--text-muted);
  margin-top: 2px;
}

.cust-points {
  font-size: calc(14px * var(--fs));
  color: var(--amber);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Placeholders */
.search-placeholder {
  padding: 20px 16px;
  color: var(--text-dim);
  font-size: calc(14px * var(--fs));
  text-align: center;
}

.search-placeholder p { margin-bottom: 4px; }
.search-placeholder .hint { opacity: 0.8; }

/* Quick categories */
#quick-categories {
  border-top: 1px solid var(--border);
  padding: 10px;
  flex-shrink: 0;
}

.section-label {
  font-size: calc(12px * var(--fs));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 7px;
}

#category-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cat-btn {
  padding: 7px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: calc(14px * var(--fs));
  cursor: pointer;
  transition: all 0.1s;
}

.cat-btn:hover, .cat-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Guest section */
.guest-section {
  padding: 12px;
  flex-shrink: 0;
}

.divider-text {
  text-align: center;
  color: var(--text-dim);
  font-size: calc(14px * var(--fs));
  margin-bottom: 10px;
}

/* ─── PAYMENT TAB ─── */
.payment-warn {
  margin: 14px;
  padding: 13px 14px;
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: var(--radius);
  color: var(--amber);
  font-size: calc(15px * var(--fs));
}

#payment-summary {
  text-align: center;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.pay-customer-name {
  font-size: calc(16px * var(--fs));
  color: var(--text-muted);
  margin-bottom: 4px;
}

.pay-label {
  font-size: calc(14px * var(--fs));
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.pay-amount {
  font-size: calc(52px * var(--fs));
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.pay-items-count {
  font-size: calc(14px * var(--fs));
  color: var(--text-muted);
  margin-top: 4px;
}

#payment-methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
}

.btn-payment {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 90px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-size: calc(15px * var(--fs));
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-payment:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.pay-icon { font-size: 28px; }

/* Payment subpanels */
.subpanel-title {
  font-size: calc(18px * var(--fs));
  font-weight: 700;
  color: var(--text);
  padding: 14px 14px 6px;
}

.subpanel-due {
  font-size: calc(16px * var(--fs));
  color: var(--text-muted);
  padding: 0 14px 12px;
}

.input-label {
  display: block;
  font-size: calc(13px * var(--fs));
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 0 14px 6px;
}

.cash-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  margin: 0 14px 10px;
  overflow: hidden;
  transition: border-color 0.15s;
}

.cash-input-wrap:focus-within { border-color: var(--accent); }

.currency-sign {
  padding: 0 6px 0 12px;
  font-size: calc(18px * var(--fs));
  font-weight: 700;
  color: var(--text-muted);
}

#cash-amount, #check-number {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: calc(22px * var(--fs));
  font-weight: 700;
  padding: 10px 10px;
  font-variant-numeric: tabular-nums;
}

.text-input {
  width: calc(100% - 28px);
  margin: 0 14px 10px;
  background: var(--bg-input);
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-size: calc(16px * var(--fs));
  padding: 10px 12px;
  outline: none;
  display: block;
  transition: border-color 0.15s;
}

.text-input:focus { border-color: var(--accent); }

.quick-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 14px 12px;
}

.change-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 4px 14px 12px;
  padding: 10px 12px;
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: var(--radius);
  font-size: calc(15px * var(--fs));
  font-weight: 600;
  color: var(--text);
}

.change-amount { font-size: calc(22px * var(--fs)); color: var(--green); }

/* Card waiting */
.card-waiting-box {
  text-align: center;
  padding: 24px 16px 16px;
}

.card-anim {
  font-size: 56px;
  animation: pulse 1.5s ease-in-out infinite;
  display: block;
  margin-bottom: 12px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.95); }
}

.card-instruction {
  font-size: calc(19px * var(--fs));
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.card-amount-display {
  font-size: calc(36px * var(--fs));
  font-weight: 800;
  color: var(--accent);
}

/* ─── FOOTER ─── */
#bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-header);
  border-top: 2px solid var(--border);
  padding: 0 10px;
  gap: 6px;
  flex-shrink: 0;
}

body.light #bottom-bar { box-shadow: 0 -1px 4px rgba(0,0,0,0.08); }

.footer-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-pay-footer {
  height: 50px;
  padding: 0 28px;
  background: var(--green);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: calc(18px * var(--fs));
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
  letter-spacing: 0.03em;
}

.btn-pay-footer:hover { background: var(--green-dark); }

.btn-pay-footer kbd {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.3);
  color: white;
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: none;
  border-radius: var(--radius);
  font-size: calc(15px * var(--fs));
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  padding: 9px 14px;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-footer {
  height: 44px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: calc(14px * var(--fs));
  padding: 0 12px;
}

.btn-footer:hover { background: var(--bg-hover); color: var(--text); }
.btn-footer.btn-danger { background: var(--red); color: white; border-color: var(--red); }
.btn-footer.btn-danger:hover { background: var(--red-dark); color: white; border-color: var(--red-dark); }

.btn-sm {
  padding: 7px 12px;
  font-size: calc(14px * var(--fs));
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
}

.btn-sm:hover { background: var(--bg-hover); color: var(--text); }

.btn-outline {
  background: none;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
}

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

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-muted);
}

.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }

.btn-danger {
  background: var(--red);
  color: white;
}

.btn-danger:hover { background: var(--red-dark); }

.btn-danger-outline {
  background: none;
  border: 1px solid var(--red);
  color: var(--red);
}

.btn-danger-outline:hover { background: var(--red); color: white; }

.btn-success {
  background: var(--green);
  color: white;
}

.btn-success:hover { background: var(--green-dark); }
.btn-success:disabled { background: var(--text-dim); }

.btn-full { width: 100%; margin-bottom: 8px; }

.btn-xl {
  height: 58px;
  font-size: calc(18px * var(--fs));
}

.btn-xl-icon {
  width: 52px;
  height: 52px;
  font-size: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: all 0.1s;
}

.btn-xl-icon:hover { background: var(--accent); border-color: var(--accent); color: white; }

.btn-modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: calc(18px * var(--fs));
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-modal-close:hover { background: var(--bg-hover); color: var(--text); }

/* ─── MODALS ─── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 100;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

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

.modal {
  display: none;
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: 400px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  flex-direction: column;
}

.modal.active { display: flex; }
.modal-wide { width: 460px; }
.modal-sm { width: 320px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: calc(19px * var(--fs));
  font-weight: 700;
  color: var(--text);
}

.modal-body {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Discount modal */
.modal-tabs {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 14px;
  gap: 3px;
}

.modal-tab {
  flex: 1;
  padding: 9px;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: calc(15px * var(--fs));
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.modal-tab.active {
  background: var(--accent);
  color: white;
}

.discount-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color 0.15s;
}

.discount-input-wrap:focus-within { border-color: var(--accent); }

#discount-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: calc(28px * var(--fs));
  font-weight: 700;
  padding: 10px 12px;
  text-align: right;
}

#discount-unit {
  font-size: calc(20px * var(--fs));
  font-weight: 700;
  color: var(--text-muted);
  padding-right: 12px;
}

.quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.modal-scope {
  display: flex;
  gap: 20px;
  margin-bottom: 14px;
  font-size: calc(15px * var(--fs));
  color: var(--text-muted);
}

.modal-scope label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* Qty modal */
.qty-edit-name {
  text-align: center;
  font-size: calc(16px * var(--fs));
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.qty-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

#qty-input {
  width: 80px;
  background: var(--bg-input);
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-size: calc(24px * var(--fs));
  font-weight: 700;
  padding: 8px;
  text-align: center;
  outline: none;
}

#qty-input:focus { border-color: var(--accent); }

/* Note modal */
#note-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-size: calc(16px * var(--fs));
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  margin-bottom: 12px;
  font-family: inherit;
}

#note-input:focus { border-color: var(--accent); }

/* Receipt modal */
.receipt-check {
  width: 64px;
  height: 64px;
  background: var(--green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: white;
  margin: 0 auto 16px;
}

#receipt-summary {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  font-size: calc(15px * var(--fs));
  color: var(--text-muted);
  line-height: 2;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
}

.receipt-row strong { color: var(--text); }

.receipt-options {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 12px;
}

.confirm-msg {
  font-size: calc(16px * var(--fs));
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.6;
}

/* ─── TOASTS ─── */
#toast-container {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: 20px;
  font-size: calc(15px * var(--fs));
  font-weight: 600;
  color: white;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  animation: toast-in 0.25s ease;
  white-space: nowrap;
}

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

.toast-success { background: var(--green); }
.toast-error   { background: var(--red); }
.toast-info    { background: var(--accent); }
.toast-warning { background: var(--amber); }

/* ─── PRODUCT INFO MODAL ─── */

.modal-info {
  width: min(860px, 96vw);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.info-modal-header {
  align-items: flex-start;
  gap: 12px;
}

.info-header-text { flex: 1; min-width: 0; }
.info-header-text h2 { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info-sub { font-size: calc(12px * var(--fs)); color: var(--text-dim); margin-top: 3px; }

.info-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.info-price {
  font-size: calc(22px * var(--fs));
  font-weight: 800;
  color: var(--red);
  white-space: nowrap;
}

/* Body: two-column grid */
.info-modal-body {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 24px;
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

/* Gallery */
.info-gallery {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-gallery-main {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  aspect-ratio: 4 / 3;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.info-gallery-main img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.45);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: calc(22px * var(--fs));
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.gallery-nav:hover { background: rgba(0,0,0,0.72); }
.gallery-prev { left: 8px; }
.gallery-next { right: 8px; }

.info-gallery-counter {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.5);
  color: white;
  font-size: calc(11px * var(--fs));
  padding: 2px 10px;
  border-radius: 10px;
  white-space: nowrap;
}

.info-gallery-thumbs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.gallery-thumb {
  width: 58px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.65;
  transition: all 0.15s;
}

.gallery-thumb:hover { opacity: 1; }
.gallery-thumb.active { border-color: var(--red); opacity: 1; }

/* Details panel */
.info-details {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
}

.info-stock-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.info-stock-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: center;
}

.stock-num {
  font-size: calc(30px * var(--fs));
  font-weight: 800;
  color: var(--green);
  line-height: 1.1;
}

.info-on-order .stock-num { color: var(--accent); }

.stock-lbl {
  font-size: calc(11px * var(--fs));
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 3px;
}

.info-section-title {
  font-size: calc(11px * var(--fs));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin: 0 0 8px;
}

.info-desc {
  font-size: calc(14px * var(--fs));
  color: var(--text-muted);
  line-height: 1.65;
  margin: 0 0 20px;
}

.info-specs {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
}

.info-specs tr { border-bottom: 1px solid var(--border); }
.info-specs tr:last-child { border-bottom: none; }

.spec-label {
  font-size: calc(13px * var(--fs));
  color: var(--text-dim);
  padding: 7px 14px 7px 0;
  width: 42%;
  vertical-align: top;
}

.spec-value {
  font-size: calc(13px * var(--fs));
  color: var(--text);
  font-weight: 500;
  padding: 7px 0;
  vertical-align: top;
}

.spec-empty {
  font-size: calc(13px * var(--fs));
  color: var(--text-dim);
  padding: 8px 0;
  font-style: italic;
}

/* Footer */
.info-modal-footer {
  display: flex;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.info-modal-footer .btn { min-width: 120px; }

/* Narrow screens: stack gallery above details */
@media (max-width: 620px) {
  .info-modal-body { grid-template-columns: 1fr; }
  .modal-info { max-height: 95vh; }
}

/* ─── SCROLLBAR GLOBAL ─── */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

/* ─── FRACTION / DECIMAL QTY PICKER ─── */
.frac-product-name {
  font-size: calc(13px * var(--fs));
  color: var(--text-muted);
  margin-top: 2px;
}

.frac-price-per {
  text-align: center;
  font-size: calc(15px * var(--fs));
  color: var(--text-muted);
  padding: 8px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.frac-price-per strong {
  color: var(--green);
  font-size: calc(18px * var(--fs));
}

.frac-section-label {
  font-size: calc(12px * var(--fs));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.frac-whole-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

#frac-whole-input {
  width: 80px;
  background: var(--bg-input);
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-size: calc(26px * var(--fs));
  font-weight: 700;
  padding: 8px;
  text-align: center;
  outline: none;
}

#frac-whole-input:focus { border-color: var(--accent); }

.frac-btn-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 20px;
}

.frac-btn {
  height: 56px;
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-size: calc(20px * var(--fs));
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.frac-btn:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--accent); }

.frac-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Decimal entry */
.frac-decimal-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
  transition: border-color 0.15s;
}

.frac-decimal-wrap:focus-within { border-color: var(--accent); }

#frac-decimal-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: calc(28px * var(--fs));
  font-weight: 700;
  padding: 12px 14px;
  font-variant-numeric: tabular-nums;
}

.frac-unit-badge {
  padding: 0 14px;
  font-size: calc(16px * var(--fs));
  font-weight: 700;
  color: var(--text-muted);
}

/* Total bar */
.frac-total-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 14px;
}

#frac-qty-display {
  font-size: calc(18px * var(--fs));
  font-weight: 700;
  color: var(--text);
}

#frac-total-price {
  font-size: calc(22px * var(--fs));
  font-weight: 800;
  color: var(--green);
}

/* Fractional qty badge in order items */
.item-qty-frac {
  font-size: calc(15px * var(--fs));
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  line-height: 1.2;
}

.item-qty-unit {
  font-size: calc(10px * var(--fs));
  color: var(--text-dim);
  display: block;
}

/* ─── TOUCH / RESPONSIVE ─── */
@media (max-width: 768px) {
  #main { grid-template-columns: 1fr; }
  #order-panel { display: none; }
  #action-panel { flex: 1; }
  .header-shortcuts { display: none; }
}

@media (pointer: coarse) {
  .order-item { padding: 14px; }
  .tab { height: 58px; }
  .btn-footer { height: 50px; }
  .btn-pay-footer { height: 54px; }
  .search-result { padding: 16px; }
  .customer-result { padding: 16px; }
  .btn-payment { height: 100px; }
  .result-add-btn, .result-info-btn { width: 40px; height: 40px; }
  .item-del-btn { width: 40px; height: 40px; }
}
