/* BOB JUICE POS — Premium Dark / Light Business Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;700&display=swap');

html, body {
  direction: ltr;
  text-align: left;
}

/* Arabic UI wrappers — PDF embeds the same Cairo TTF via pdf_fonts.py */
.ar-text {
  font-family: 'Cairo', sans-serif;
  direction: rtl;
}

#admin-app, .admin-main, .admin-content, .sidebar, .modal {
  direction: ltr;
  text-align: left;
}

/* ── Dark (default luxury charcoal) ── */
:root, [data-theme="dark"] {
  --bg-page: #121212;
  --bg-surface: #1a1a1a;
  --bg-elevated: #242424;
  --bg-dark: #0d0d0d;
  --bg-dark-soft: #2a2a2a;
  --text-primary: #f5f5f5;
  --text-secondary: #a3a3a3;
  --text-inverse: #fafafa;
  --border: #333333;
  --border-strong: #404040;
  --accent: #f97316;
  --accent-gold: #facc15;
  --accent-hover: #ea580c;
  --accent-soft: rgba(249, 115, 22, 0.12);
  --success: #34d399;
  --danger: #f87171;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  --topbar-bg: #0d0d0d;
  --receipt-bg: #161616;
  --tile-bg: #1e1e1e;
  --input-bg: #242424;
}

/* ── Light enterprise ── */
[data-theme="light"] {
  --bg-page: #f0f2f5;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --bg-dark: #111827;
  --bg-dark-soft: #374151;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-inverse: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --accent: #ea580c;
  --accent-gold: #ca8a04;
  --accent-hover: #c2410c;
  --accent-soft: #fff7ed;
  --success: #059669;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --topbar-bg: #111827;
  --receipt-bg: #fafafa;
  --tile-bg: #ffffff;
  --input-bg: #ffffff;
}

:root {
  --radius: 10px;
  --radius-lg: 14px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; font-family: var(--font); color: var(--text-primary); background: var(--bg-page); transition: background .2s, color .2s; }
body.pos-lock { overflow: hidden; height: 100vh; }

.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.settings-sync-card { background: linear-gradient(135deg, var(--bg-surface) 0%, rgba(51, 78, 78, 0.35) 100%); border-color: var(--accent); box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.12), var(--shadow); }
.settings-sync-card #btn-sync-time { box-shadow: 0 4px 14px rgba(45, 212, 191, 0.25); }
.receipt-logo-circle,
.receipt-print-logo img,
#print-area .receipt-logo-circle,
#print-area img.receipt-logo-circle {
  border-radius: 50% !important;
  object-fit: cover !important;
  width: 60px !important;
  height: 60px !important;
  aspect-ratio: 1 / 1 !important;
  border: 2px solid #334e4e !important;
  display: inline-block !important;
}
.badge-warn { background: rgba(251, 146, 60, .18); color: #fb923c; }
.badge-success { background: rgba(74, 222, 128, .15); color: #4ade80; }
.inv-row-low td { background: rgba(248, 113, 113, .06); }
.inv-low-badge { font-weight: 800; letter-spacing: .02em; }
.card-dark { background: var(--bg-dark); color: var(--text-inverse); border-color: var(--border-strong); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .625rem 1.125rem; border-radius: var(--radius); font-weight: 600; font-size: .875rem; border: 1px solid transparent; cursor: pointer; transition: all .15s ease; font-family: inherit; min-height: 44px; }
.btn:active { transform: scale(.98); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-hover)); color: #fff; border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; filter: none; }
.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-danger { background: rgba(248,113,113,.12); color: var(--danger); border-color: rgba(248,113,113,.3); }
.btn-danger:hover { background: rgba(248,113,113,.22); border-color: var(--danger); }
.btn-success { background: rgba(74,222,128,.14); color: #4ade80; border-color: rgba(74,222,128,.35); }
.btn-success:hover { background: rgba(74,222,128,.24); border-color: #4ade80; }
.btn-lg { padding: .875rem 1.5rem; font-size: 1rem; min-height: 52px; }
.btn-touch { min-height: 56px; min-width: 56px; }
.btn-sm { min-height: 36px; padding: .375rem .75rem; font-size: .8125rem; }

.input, .select, .textarea, .form-control {
  width: 100%; padding: .625rem .875rem; border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-size: .875rem; font-family: inherit; background: var(--input-bg); color: var(--text-primary);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-group { margin-bottom: .75rem; }
.input-group label { display: block; font-size: .6875rem; font-weight: 700; color: var(--text-secondary); margin-bottom: .25rem; text-transform: uppercase; letter-spacing: .04em; }
.input-tip { font-size: .6875rem; color: var(--text-secondary); margin-top: .2rem; }

/* Theme toggle */
.theme-toggle { position: relative; width: 52px; height: 28px; border-radius: 999px; background: var(--bg-dark-soft); border: 1px solid var(--border-strong); cursor: pointer; padding: 0; flex-shrink: 0; }
.theme-toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent-gold); transition: transform .2s; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
[data-theme="light"] .theme-toggle::after { transform: translateX(24px); background: var(--accent); }

.badge { display: inline-flex; padding: .2rem .5rem; border-radius: 999px; font-size: .6875rem; font-weight: 700; }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-dark { background: var(--bg-dark-soft); color: var(--text-inverse); }
.badge-success { background: rgba(52,211,153,.15); color: var(--success); }
.badge-danger { background: rgba(248,113,113,.15); color: var(--danger); }

.topbar { background: var(--topbar-bg); color: var(--text-inverse); padding: .75rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--border); }
.topbar-brand { display: flex; align-items: center; gap: .75rem; }
.topbar-brand > img:not(.brand-logo) { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; border: 2px solid #334e4e; }
.brand-logo-wrap { display: inline-flex; align-items: center; justify-content: center; line-height: 0; background: transparent; overflow: hidden; border-radius: 50%; }
.brand-logo {
  display: block;
  border-radius: 50% !important;
  object-fit: cover !important;
  width: 60px !important;
  height: 60px !important;
  border: 2px solid #334e4e !important;
  background: transparent !important;
  box-shadow: none;
}
.brand-logo--login {
  width: 108px !important;
  height: 108px !important;
  margin: 0 auto .65rem;
  border: 2px solid #334e4e !important;
}
.brand-logo--topbar { width: 60px !important; height: 60px !important; }
.brand-logo--sidebar { width: 60px !important; height: 60px !important; margin: 0 auto .65rem; }
.brand-logo-wrap--login,
.brand-logo-wrap--sidebar,
.brand-logo-wrap--topbar { background: transparent !important; padding: 0; border-radius: 50%; width: 60px; height: 60px; }
.brand-logo-wrap--login { width: 108px; height: 108px; }
.brand-logo { mix-blend-mode: normal; }
[data-theme="dark"] .brand-logo,
[data-theme="light"] .brand-logo { mix-blend-mode: normal; }
.portal-logo {
  border-radius: 50% !important;
  object-fit: cover !important;
  width: 108px !important;
  height: 108px !important;
  border: 2px solid #334e4e !important;
  display: inline-block;
  background: transparent !important;
}
.portal-logo-wrap { text-align: center; margin-bottom: 1rem; line-height: 0; display: flex; justify-content: center; }
.receipt-print-logo { text-align: center; margin: 0 0 4px; }
.receipt-print-logo img {
  border-radius: 50% !important;
  object-fit: cover !important;
  width: 60px !important;
  height: 60px !important;
  border: 2px solid #334e4e !important;
  display: inline-block !important;
}
.login-brand { text-align: center; margin-bottom: 1.25rem; padding: .5rem 0; }
.login-brand p { color: var(--text-secondary); margin: .35rem 0 0; font-size: .875rem; }
.topbar-title { font-weight: 800; font-size: 1.0625rem; letter-spacing: -.02em; }
.topbar-sub { font-size: .6875rem; color: #9ca3af; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.rate-bar {
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
  padding: .3rem .75rem; display: flex; flex-direction: row; flex-wrap: nowrap;
  align-items: center; gap: .625rem; font-size: .75rem; color: var(--text-secondary);
  min-height: 34px; overflow: hidden;
}
.rate-bar-item { white-space: nowrap; flex-shrink: 0; }
.rate-bar strong { color: var(--accent-gold); }
.rate-bar-search:focus { border-color: var(--accent-gold); outline: none; box-shadow: 0 0 0 2px rgba(250,204,21,.12); }

.pos-catalog-toolbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: .5rem .875rem 0;
  flex-shrink: 0;
}
.pos-catalog-toolbar #search-products {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  max-width: none;
  margin: 0;
  padding: .375rem .75rem;
  font-size: .8125rem;
  min-height: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-sizing: border-box;
  font-family: inherit;
}
.pos-catalog-toolbar #search-products:focus {
  border-color: var(--accent-gold);
  outline: none;
  box-shadow: 0 0 0 2px rgba(250,204,21,.12);
}
.pos-catalog-toolbar-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
}
.pos-catalog-toolbar-actions .cat-pill {
  flex: 0 0 auto;
  margin: 0;
}

/* POS layout */
.pos-layout { display: flex; flex: 1; overflow: hidden; }

.receipt-panel {
  width: 38%; max-width: 400px; min-width: 280px; min-height: 0;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--receipt-bg); border-right: 1px solid var(--border);
}
.receipt-head { padding: .625rem .875rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.receipt-head-compact { padding: .25rem .5rem .15rem; }
.receipt-head h2 { margin: 0; font-size: .875rem; font-weight: 800; }
.receipt-head-compact h2 { font-size: .75rem; }
.rcpt-meta { margin: .0625rem 0 0; font-size: .5625rem; color: var(--text-secondary); line-height: 1.15; }
.receipt-lines { flex: 1 1 0; overflow-y: auto; padding: .125rem .35rem; min-height: 0; }
.receipt-empty { text-align: center; color: var(--text-secondary); padding: .5rem; font-size: .6875rem; margin: 0; }
.receipt-foot-mini { padding: .5rem .625rem; border-top: 1px solid var(--border); background: var(--bg-surface); flex-shrink: 0; }
.receipt-foot-compact { padding: .0625rem .35rem .1rem; flex-shrink: 0; }
.totals-mini .totals-row { font-size: .5625rem; margin-bottom: 0; line-height: 1.2; }
.totals-mini.totals-block { margin-bottom: 0; }
.total-grand-mini { padding: .0625rem 0; margin: .0625rem 0 .0625rem; border-top-width: 1px; }
.total-grand-mini .label { font-size: .625rem; }
.total-grand-mini .usd { font-size: .875rem; line-height: 1.1; }
.total-grand-mini .lbp { font-size: .5rem; line-height: 1.1; }
.checkout-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: .1rem; margin-bottom: .0625rem; }
.checkout-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: .1rem; }
.checkout-actions-primary { gap: .25rem; margin-top: .0625rem; margin-bottom: .0625rem; }
.checkout-actions-primary .btn-pos-action {
  min-height: 42px; padding: .45rem .65rem; font-size: .8125rem; font-weight: 800;
  border-radius: var(--radius-lg); letter-spacing: .02em;
}
.checkout-actions-primary #btn-clear.btn-pos-action {
  border: 2px solid var(--border-strong); background: var(--bg-elevated); color: var(--text-primary);
}
.checkout-actions-primary #btn-pay.btn-pos-action {
  border: 2px solid transparent; box-shadow: 0 2px 8px rgba(249, 115, 22, 0.35);
}
.checkout-actions-primary #btn-pay.btn-pos-action:disabled { opacity: .45; box-shadow: none; }
.change-due { margin: .375rem 0 .25rem; padding: .5rem .625rem; border-radius: var(--radius); background: rgba(52, 211, 153, 0.12); border: 1px solid rgba(52, 211, 153, 0.35); }
.change-due-compact { margin: .0625rem 0; padding: .15rem .3rem; }
.change-due-compact .change-due-label { margin-bottom: 0; font-size: .5rem; }
.change-due-compact .change-due-amt #change-due-primary { font-size: .875rem; }
.change-due-compact .change-due-amt #change-due-secondary { font-size: .5625rem; }
.change-due.hidden { display: none !important; }
.change-due-label { font-size: .625rem; font-weight: 700; color: var(--success); text-transform: uppercase; letter-spacing: .03em; margin-bottom: .2rem; }
.change-due-amt { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.change-due-amt #change-due-primary { font-size: 1.25rem; font-weight: 800; color: var(--success); }
.change-due-amt #change-due-secondary { font-size: .6875rem; color: var(--text-secondary); font-weight: 600; }
.overlay.shift-required { pointer-events: auto; z-index: 50; }
.shift-modal { max-width: 400px; border: 2px solid var(--accent-gold); }
.input-xs, .btn-xs { min-height: 22px; padding: .15rem .25rem; font-size: .5625rem; border-radius: 5px; }
.btn-xs { font-weight: 700; }

.prod-toggle-label { display: flex; align-items: center; gap: .5rem; font-weight: 600; font-size: .875rem; cursor: pointer; user-select: none; }
.prod-toggle-label input { width: auto; accent-color: var(--accent); }
.product-search { font-size: .9375rem; padding: .625rem .875rem; border-radius: var(--radius-lg); background: var(--bg-elevated); }
.product-search:focus { border-color: var(--accent-gold); box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.15); }

.totals-block { margin-bottom: .625rem; }
.totals-row { display: flex; justify-content: space-between; font-size: .8125rem; margin-bottom: .2rem; color: var(--text-secondary); }
.totals-row .dual-amt { text-align: right; }
.totals-row .dual-amt .usd { font-weight: 700; color: var(--text-primary); }
.totals-row .dual-amt .lbp { font-size: .6875rem; color: var(--text-secondary); }
.total-grand { display: flex; justify-content: space-between; align-items: baseline; padding: .5rem 0; border-top: 2px solid var(--accent); margin: .375rem 0 .625rem; }
.total-grand .label { font-weight: 800; font-size: .875rem; }
.total-grand .usd { font-size: 1.625rem; font-weight: 800; color: var(--accent); line-height: 1; }
.total-grand .lbp { font-size: .75rem; color: var(--accent-gold); font-weight: 600; text-align: right; }

.checkout-compact { display: grid; grid-template-columns: 1fr 1fr; gap: .375rem .5rem; margin-bottom: .5rem; }
.checkout-compact .input-group { margin-bottom: 0; }
.checkout-compact .span-2 { grid-column: 1 / -1; }
.checkout-compact .select, .checkout-compact .input { padding: .5rem .625rem; font-size: .8125rem; min-height: 36px; }

.discount-row { display: grid; grid-template-columns: 1fr 80px; gap: .375rem; margin-bottom: .5rem; }
.discount-row .select, .discount-row .input { min-height: 36px; font-size: .8125rem; padding: .5rem; }

.menu-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg-page); position: relative; min-width: 0; }
.cat-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: .375rem .875rem; overflow: visible; border-bottom: 1px solid var(--border); background: var(--bg-surface); flex-shrink: 0; }
.menu-catalog-layout { flex: 1; display: flex; min-height: 0; overflow: hidden; }
.menu-catalog-main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.menu-grid { flex: 1; overflow-y: auto; padding: .75rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .625rem; align-content: start; }

/* POS product tiles — dark theme cards with orange USD / blue LBP prices */
.menu-tile {
  background: var(--tile-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .875rem;
  text-align: left;
  cursor: pointer;
  transition: border-color .12s, transform .12s, box-shadow .12s, background .12s;
  min-height: 100px;
  font-family: inherit;
  color: var(--text-primary);
  touch-action: manipulation;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.menu-tile:hover {
  border-color: var(--accent);
  background: #252525;
  box-shadow: 0 0 0 1px var(--accent-soft), 0 4px 12px rgba(249,115,22,.18);
}
.menu-tile:active { transform: scale(.97); }
.menu-tile .name { font-weight: 700; font-size: .8125rem; margin: 0 0 .2rem; line-height: 1.25; color: var(--text-primary); }
.menu-tile .cat-tag { font-size: .625rem; color: var(--text-secondary); margin-bottom: .25rem; }
.menu-tile .price { font-weight: 800; font-size: 1rem; color: var(--accent); line-height: 1.2; }
.menu-tile .price-lbp { font-size: .6875rem; font-weight: 700; color: #38bdf8; margin-top: .1rem; }
.menu-tile--multi { border-color: rgba(249,115,22,.45); }
.menu-tile--multi:hover { border-color: var(--accent); }
[data-theme="light"] .menu-tile { background: var(--tile-bg); box-shadow: var(--shadow); }
[data-theme="light"] .menu-tile:hover { background: #fff7ed; }
[data-theme="light"] .menu-tile .price-lbp { color: #0284c7; }

/* Extras / Excludes — large square touch cards */
.pos-mod-column {
  width: 132px; flex-shrink: 0; border-left: 1px solid var(--border); background: var(--bg-page);
  display: flex; flex-direction: column; gap: .625rem; padding: .625rem; justify-content: stretch;
}
.pos-mod-box {
  flex: 1; min-height: 128px; aspect-ratio: 1 / 1; max-height: calc(50% - .3125rem);
  border: none; border-radius: var(--radius-lg); padding: .625rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-family: inherit; touch-action: manipulation;
  box-shadow: 0 4px 14px rgba(0,0,0,.28);
  transition: transform .1s, filter .1s, box-shadow .12s;
  color: #fff;
}
.pos-mod-box:active { transform: scale(.95); filter: brightness(.9); }
.pos-mod-box-text {
  font-size: 1.3125rem; font-weight: 900; line-height: 1.05; text-align: center;
  letter-spacing: .04em; text-transform: uppercase; color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,.35);
}
.pos-mod-box--extra { background: #15803d; color: #fff; }
.pos-mod-box--extra:hover, .pos-mod-box--extra.active {
  background: #16a34a; box-shadow: 0 0 0 3px rgba(74,222,128,.45);
}
.pos-mod-box--exclude { background: #b91c1c; color: #fff; }
.pos-mod-box--exclude:hover, .pos-mod-box--exclude.active {
  background: #dc2626; box-shadow: 0 0 0 3px rgba(248,113,113,.45);
}
.receipt-note-wrap { padding: .125rem .35rem .0625rem; flex-shrink: 0; border-bottom: 1px solid var(--border); background: var(--bg-surface); }
.receipt-note-wrap .receipt-note-input { width: 100%; box-sizing: border-box; margin: 0; font-size: .75rem; padding: .3rem .45rem; min-height: 28px; border-radius: var(--radius); background: var(--bg-elevated); }
.receipt-line-selected { outline: 2px solid var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }

.menu-tile-mod-extra { border-color: rgba(74, 222, 128, 0.35); background: rgba(74, 222, 128, 0.08); }
.menu-tile-mod-extra:hover { border-color: #4ade80; box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.25); }
.menu-tile-mod-extra .price { color: #4ade80; }
.menu-tile-mod-exclude { border-color: rgba(248, 113, 113, 0.35); background: rgba(248, 113, 113, 0.08); }
.menu-tile-mod-exclude:hover { border-color: var(--danger); box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.25); }
.menu-tile-mod-exclude .price { color: #fca5a5; }
.menu-grid-empty { grid-column: 1 / -1; text-align: center; color: var(--text-secondary); padding: 2rem; font-size: .8125rem; margin: 0; }

.receipt-line-block { margin-bottom: .15rem; border-radius: var(--radius); }
.receipt-line-block-selected { outline: 2px solid var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }
.receipt-line-block .receipt-line { margin-bottom: 0; }
.receipt-modifiers { padding: 0 .35rem .15rem .85rem; }
.receipt-mod-line { font-size: .5625rem; line-height: 1.25; padding: .05rem 0; font-weight: 600; }
.receipt-mod-extra { color: #86efac; }
.receipt-mod-exclude { color: #fca5a5; }
.receipt-mod-price { opacity: .9; font-weight: 700; }

.receipt-line {
  display: grid; grid-template-columns: 1fr auto auto; gap: .2rem; align-items: center;
  padding: .2rem .3rem; border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 0; background: var(--bg-elevated); font-size: .6875rem;
}
.receipt-line-name { font-weight: 700; line-height: 1.2; }
.receipt-line-cat { font-size: .5625rem; color: var(--text-secondary); }
.receipt-qty { width: 18px; text-align: center; font-weight: 700; font-size: .75rem; }
.receipt-line .line-prices { text-align: right; }
.receipt-line .line-prices .usd { font-weight: 800; font-size: .75rem; }
.receipt-line .line-prices .lbp { font-size: .5625rem; color: var(--text-secondary); }
.qty-ctrl { display: flex; align-items: center; gap: .15rem; }
.qty-ctrl button { min-width: 22px; min-height: 22px; padding: 0; font-size: .75rem; }

.cat-pill { padding: .4375rem .875rem; border-radius: 999px; font-size: .75rem; font-weight: 700; border: 1px solid var(--border); background: var(--bg-elevated); cursor: pointer; white-space: nowrap; font-family: inherit; color: var(--text-primary); transition: all .12s; }
.cat-pill:hover { border-color: var(--accent); }
.cat-pill.active { background: linear-gradient(135deg, var(--accent), var(--accent-hover)); color: #fff; border-color: transparent; }
.cat-pill-extra { border-color: rgba(74, 222, 128, 0.45); color: #86efac; background: rgba(74, 222, 128, 0.1); font-weight: 800; }
.cat-pill-extra:hover { border-color: #4ade80; }
.cat-pill-extra.active { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; border-color: transparent; }
.cat-pill-exclude { border-color: rgba(248, 113, 113, 0.45); color: #fca5a5; background: rgba(248, 113, 113, 0.1); font-weight: 800; }
.cat-pill-exclude:hover { border-color: var(--danger); }
.cat-pill-exclude.active { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; border-color: transparent; }

.size-picker-overlay {
  position: fixed; inset: 0; z-index: 99999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(2px);
  touch-action: manipulation; pointer-events: auto;
}
.size-picker-overlay.hidden { display: none !important; }
.size-picker-pop {
  background: var(--bg-surface); border: 2px solid var(--accent);
  border-radius: var(--radius-lg); padding: 1.25rem 1.5rem; min-width: 340px; max-width: 92vw;
  box-shadow: 0 8px 32px rgba(0,0,0,.55); text-align: center;
}
.size-picker-title { font-weight: 800; font-size: 1.125rem; margin-bottom: 1rem; color: var(--text-primary); }
.size-picker-btns { display: flex; gap: .625rem; justify-content: center; flex-wrap: wrap; }
.size-picker-btn {
  flex: 1; min-width: 96px; max-width: 140px; padding: .75rem .4rem; border-radius: var(--radius-lg);
  border: 2px solid var(--border); background: var(--tile-bg);
  cursor: pointer; font-family: inherit; touch-action: manipulation;
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  transition: border-color .1s, background .1s, transform .1s, box-shadow .1s;
  color: var(--text-primary);
}
.size-picker-lbl { font-weight: 900; font-size: .8125rem; line-height: 1.15; color: var(--text-primary); }
.size-picker-pr { font-weight: 800; font-size: .75rem; color: var(--accent); line-height: 1.2; }
.size-picker-btn:hover, .size-picker-btn:focus {
  border-color: var(--accent); background: rgba(249, 115, 22, 0.15);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.size-picker-btn-m { border-color: var(--accent); background: rgba(249, 115, 22, 0.2); }
.size-picker-btn:active { transform: scale(.95); }

/* Admin */
.sidebar { width: 240px; background: var(--topbar-bg); color: var(--text-inverse); display: flex; flex-direction: column; min-height: 100vh; flex-shrink: 0; border-right: 1px solid var(--border); }
.sidebar-nav { flex: 1; padding: .625rem; display: flex; flex-direction: column; gap: .2rem; overflow-y: auto; }
.sidebar-link { display: block; padding: .6875rem 1rem; border-radius: var(--radius); color: #d1d5db; text-decoration: none; font-weight: 600; font-size: .8125rem; transition: background .15s; border: none; background: none; width: 100%; text-align: left; cursor: pointer; font-family: inherit; }
.sidebar-link:hover { background: var(--bg-dark-soft); color: #fff; }
.sidebar-link.active { background: linear-gradient(135deg, var(--accent), var(--accent-hover)); color: #fff; }

.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.admin-topnav {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  padding: .5rem 1.25rem;
  flex-shrink: 0;
}
.admin-topnav-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .375rem;
}
.admin-topnav-link {
  display: inline-flex;
  align-items: center;
  padding: .4375rem .875rem;
  border-radius: var(--radius);
  font-size: .75rem;
  font-weight: 700;
  color: #d1d5db;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.admin-topnav-link:hover {
  background: var(--bg-dark-soft);
  color: #fff;
  border-color: rgba(249, 115, 22, .35);
}
.dashboard-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.chart-card { padding: 1rem 1.125rem; }
.chart-card-title {
  margin: 0 0 .75rem;
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.chart-wrap {
  position: relative;
  height: 260px;
  max-height: 280px;
}
.inventory-forms-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: start;
}
.inventory-tables-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.inventory-table-scroll {
  max-height: 200px;
  overflow-y: auto;
}
.inv-suggest-wrap { position: relative; }
.inv-suggest-dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 30;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow); max-height: 220px; overflow-y: auto;
}
.inv-suggest-opt {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  width: 100%; padding: .55rem .75rem; border: none; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--text-primary); font-family: inherit; font-size: .8125rem;
  cursor: pointer; text-align: left;
}
.inv-suggest-opt:last-child { border-bottom: none; }
.inv-suggest-opt:hover, .inv-suggest-opt:focus { background: var(--accent-soft); }
.inv-suggest-name { font-weight: 700; }
.inv-suggest-meta { font-size: .75rem; color: var(--text-secondary); white-space: nowrap; }
.inventory-purchase-fields {
  border-top: 1px solid var(--border);
  margin-top: .25rem;
  padding-top: .75rem;
}
.inventory-stock-card .inventory-table-scroll { max-height: 160px; }
.admin-content { flex: 1; padding: 1.25rem; overflow-y: auto; }
.panel { display: none; }
.panel.active { display: block; }

.tab-cards { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.tab-card { padding: 1rem 1.25rem; cursor: pointer; min-width: 140px; transition: border-color .15s; }
.tab-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }
.tab-card h3 { margin: 0; font-size: .875rem; font-weight: 800; }
.tab-card p { margin: .25rem 0 0; font-size: .6875rem; color: var(--text-secondary); }

.debt-summary-card {
  padding: 1.25rem 1.5rem; margin-bottom: 1rem; border: 2px solid var(--accent);
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.08), rgba(250, 204, 21, 0.06));
  border-radius: var(--radius-lg);
}
.debt-summary-card .debt-summary-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); margin-bottom: .35rem; }
.debt-summary-card .debt-summary-usd { font-size: 1.75rem; font-weight: 800; color: var(--accent); line-height: 1.1; }
.debt-summary-card .debt-summary-lbp { font-size: .875rem; font-weight: 600; color: var(--accent-gold); margin-top: .2rem; }
.btn-status-toggle {
  border: none; cursor: pointer; font-family: inherit; font-size: inherit; font-weight: 700;
  padding: .25rem .55rem; border-radius: 999px; transition: opacity .12s, transform .1s;
}
.btn-status-toggle:hover { opacity: .88; transform: scale(1.03); }
.btn-status-toggle:active { transform: scale(.97); }
.btn-status-toggle:disabled { opacity: .5; cursor: wait; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .875rem; }
.txn-filter-bar { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr auto; gap: .75rem; align-items: end; }
.txn-filter-bar .txn-filter-search { grid-column: span 1; }
.txn-filter-actions { display: flex; gap: .35rem; padding-bottom: .1rem; }
.txn-items-cell { max-width: 280px; font-size: .8125rem; line-height: 1.35; }
.txn-table .dual-cell .usd { display: block; font-weight: 700; }
.txn-table .dual-cell .lbp { display: block; font-size: .6875rem; color: var(--text-secondary); }
@media (max-width: 900px) {
  .txn-filter-bar { grid-template-columns: 1fr 1fr; }
  .txn-filter-actions { grid-column: 1 / -1; }
}
.kpi { padding: 1rem; }
.kpi-label { font-size: .6875rem; color: var(--text-secondary); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.375rem; font-weight: 800; margin-top: .2rem; color: var(--accent); }
.kpi-sub { font-size: .6875rem; color: var(--text-secondary); margin-top: .125rem; }

table.data { width: 100%; border-collapse: collapse; font-size: .8125rem; }
table.data th { text-align: left; padding: .625rem; color: var(--text-secondary); font-weight: 700; border-bottom: 1px solid var(--border); font-size: .6875rem; text-transform: uppercase; letter-spacing: .04em; }
table.data td { padding: .625rem; border-bottom: 1px solid var(--border); }
table.data tr:hover td { background: var(--accent-soft); }
.dual-cell { text-align: right; }
.dual-cell .usd { font-weight: 700; display: block; }
.dual-cell .lbp { font-size: .6875rem; color: var(--text-secondary); }

.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .5rem; margin-top: .5rem; }
.perm-grid label { display: flex; align-items: center; gap: .375rem; font-size: .8125rem; cursor: pointer; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .875rem; }
.form-grid .span-2 { grid-column: 1 / -1; }

.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: var(--topbar-bg); color: #fff; padding: .75rem 1.25rem; border-radius: var(--radius); font-weight: 600; font-size: .875rem; z-index: 100; box-shadow: var(--shadow); border: 1px solid var(--accent); }
.toast.hidden, .overlay.hidden { display: none !important; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(6px); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--bg-surface); border-radius: var(--radius-lg); padding: 1.5rem; width: 100%; max-width: 440px; box-shadow: var(--shadow); max-height: 90vh; overflow-y: auto; border: 1px solid var(--border); }
.access-denied { text-align: center; max-width: 420px; }
.access-denied .icon { width: 72px; height: 72px; margin: 0 auto 1rem; background: rgba(248,113,113,.12); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2rem; }

.nav-back { display: inline-flex; align-items: center; gap: .375rem; color: var(--text-secondary); text-decoration: none; font-size: .875rem; font-weight: 600; }
.nav-back:hover { color: var(--accent); }

.hidden { display: none !important; }

/* Off-screen receipt host — shown only during window.print() fallback.
   Auto-adapts from 58mm to 80mm thermal rolls; height follows content. */
:root {
  --receipt-print-width: 80mm;
  --receipt-print-min-width: 58mm;
  --receipt-print-max-width: 80mm;
  --receipt-font-base: 0.75rem;
}
#print-area {
  position: fixed; left: -9999px; top: 0;
  width: 100%;
  min-width: var(--receipt-print-min-width, 58mm);
  max-width: var(--receipt-print-max-width, 80mm);
  height: auto;
  margin: 0 auto;
  background: #fff; color: #000;
  font-family: 'Courier New', Courier, monospace;
  font-size: var(--receipt-font-base, 0.75rem);
  line-height: 1.35;
  padding: 0;
  box-sizing: border-box;
}
.receipt-print-root {
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 0.15rem 0.35rem 0.25rem;
}
.receipt-print-brand { text-align: center; font-weight: 800; font-size: 1.15em; margin-bottom: 0.15em; }
.receipt-print-tagline { text-align: center; font-size: 0.85em; margin-bottom: 0.25em; }
.receipt-print-meta { font-size: 0.85em; margin-bottom: 0.4em; }
.receipt-print-hr { border: none; border-top: 1px dashed #000; margin: 0.4em 0; }
.receipt-print-line { display: flex; justify-content: space-between; gap: 0.35em; margin: 0.15em 0; word-break: break-word; }
.receipt-print-mod { font-size: 0.85em; padding-left: 0.6em; margin: 0.08em 0; }
.receipt-print-mod-extra { color: #166534; }
.receipt-print-mod-exclude { color: #991b1b; }
.receipt-print-total { font-weight: 800; font-size: 1.05em; margin-top: 0.25em; }
.receipt-print-footer { text-align: center; font-size: 0.9em; margin-top: 0.5em; font-weight: 700; }

@media print {
  @page {
    size: auto;
    margin: 0;
  }
  html, body {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }
  body * { visibility: hidden !important; }
  #print-area, #print-area * { visibility: visible !important; }
  #print-area {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    right: 0 !important;
    width: 100% !important;
    min-width: var(--receipt-print-min-width, 58mm) !important;
    max-width: var(--receipt-print-max-width, 80mm) !important;
    height: auto !important;
    margin: 0 auto !important;
    padding: 0 !important;
    color: #000 !important;
    background: #fff !important;
    page-break-after: auto;
    page-break-inside: avoid;
    overflow: visible !important;
  }
  .receipt-print-root {
    width: 100% !important;
    height: auto !important;
    margin: 0 auto !important;
    page-break-inside: avoid;
    page-break-after: auto;
  }
}

@media (max-width: 900px) {
  .pos-layout { flex-direction: column-reverse !important; }
  .receipt-panel { width: 100% !important; max-width: none !important; max-height: 45vh; min-width: 0; border-right: none; border-top: 1px solid var(--border); }
  .sidebar { display: none; }
  .dashboard-charts-grid { grid-template-columns: 1fr; }
  .inventory-forms-grid,
  .inventory-tables-grid { grid-template-columns: 1fr; }
  .admin-topnav-inner { gap: .25rem; }
}
