:root {
  --cream: #FFF8F0;
  --cream-2: #FBF1E4;
  --ink: #2B1B12;
  --ink-soft: #5B4A3D;
  --ink-faint: #B9A793;
  --terracotta: #C8442C;
  --terracotta-dark: #A6371F;
  --gold: #D4A24C;
  --sage: #5C7A5C;
  --plum: #6B4C7A;
  --line: #E9DCC8;
  --white: #FFFFFF;
  --sidebar-w: 240px;
  --topbar-h: 64px;
  --mobile-topbar-h: 56px;
  --shadow-sm: 0 2px 6px -2px rgba(43,27,18,0.08);
  --shadow-md: 0 10px 28px -12px rgba(43,27,18,0.16);
  --shadow-lg: 0 24px 56px -20px rgba(43,27,18,0.28);
  --grad-terracotta: linear-gradient(135deg, #D9502F 0%, var(--terracotta-dark) 100%);
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
html {
  /* overflow-x hidden lives on <html>, not <body> — keeping it on body
     without a matching fixed height is what breaks position:sticky
     (the topbar/sidebar) in some browsers. This keeps the page from
     scrolling sideways while letting sticky headers work correctly. */
  overflow-x: hidden;
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: var(--ink-faint) transparent; /* Firefox */
}
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  width: 100%;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-faint); border-radius: 20px; opacity: .5; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-soft); }
::selection { background: var(--terracotta); color: white; }
button, input, select { font-size: 16px; } /* prevents iOS zoom-on-focus */
.mono { font-family: 'JetBrains Mono', 'Courier New', monospace; }
.txt-muted { color: var(--ink-faint); }
.txt-danger { color: var(--terracotta); }
.txt-warning { color: var(--gold); }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }

/* Keyboard accessibility: a clear, on-brand focus ring for anyone tabbing
   through the app, without adding an outline to mouse/touch clicks. */
:focus-visible {
  outline: 2.5px solid var(--terracotta);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Subtle rise-and-fade whenever a page section becomes visible (page
   switch, opening a form) — quiet enough to feel premium, not flashy. */
@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.page { animation: pageIn .28s ease both; }
@media (prefers-reduced-motion: reduce) {
  .page { animation: none; }
}

/* ============ LOGIN ============ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, #FFFBF5 0%, var(--cream) 60%);
  padding: 20px; position: relative; overflow: hidden;
}
.login-wrap::before, .login-wrap::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(60px); opacity: .35; z-index: 0;
}
.login-wrap::before { width: 320px; height: 320px; background: var(--terracotta); top: -80px; left: -80px; }
.login-wrap::after { width: 280px; height: 280px; background: var(--sage); bottom: -100px; right: -60px; }
.login-card { position: relative; z-index: 1; }
.login-card {
  background: var(--white); border-radius: 22px; padding: 34px 30px;
  box-shadow: var(--shadow-lg); width: 100%; max-width: 380px;
  border: 1px solid var(--line);
  position: relative; overflow: hidden;
}
.login-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 5px;
  background: linear-gradient(90deg, var(--terracotta), var(--gold), var(--sage));
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-brand-icon {
  width: 56px; height: 56px; flex-shrink: 0; padding: 8px; border-radius: 14px;
  background: var(--cream-2); border: 1px solid var(--line);
}
.login-brand-name { font-family: 'Fraunces', serif; font-size: 21px; font-weight: 600; line-height: 1; }
.login-brand-sub { font-size: 12px; color: var(--ink-soft); margin-top: 4px; line-height: 1.3; }
.login-form { display: flex; flex-direction: column; }
.form-error {
  margin-top: 12px; color: var(--terracotta-dark); font-size: 13px; display: flex; align-items: center; gap: 6px;
  background: #FBE9E5; padding: 9px 11px; border-radius: 8px;
}
.login-hint { margin-top: 16px; font-size: 12px; color: var(--ink-faint); text-align: center; }

/* ============ APP FRAME ============ */
.frame { display: flex; min-height: 100vh; position: relative; }

.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }

.sidebar {
  width: var(--sidebar-w); background: linear-gradient(180deg, #2B1B12 0%, #21140D 100%); color: #F4ECE2; flex-shrink: 0;
  display: flex; flex-direction: column; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; z-index: 50;
  box-shadow: 4px 0 24px -12px rgba(0,0,0,0.35);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 20px; border-bottom: 1px solid rgba(244,236,226,0.12); margin-bottom: 16px; position: relative; }
.sidebar-brand-icon { width: 40px; height: 40px; flex-shrink: 0; padding: 6px; border-radius: 11px; background: rgba(244,236,226,0.08); }
.sidebar-brand-name { font-family: 'Fraunces', serif; font-weight: 600; font-size: 16.5px; line-height: 1.1; }
.sidebar-brand-sub { font-size: 10.5px; color: #C9B8A4; margin-top: 2px; }
.sidebar-close-btn { display: none; }
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 12px 12px; border-radius: 10px;
  background: transparent; border: none; color: #DCCFC0; font-size: 14.5px; font-weight: 500;
  cursor: pointer; text-align: left; transition: background .15s, color .15s, transform .15s; width: 100%; font-family: inherit;
  position: relative;
}
.nav-item:hover { background: rgba(244,236,226,0.08); color: white; }
.nav-item.active { background: var(--grad-terracotta); color: white; box-shadow: 0 6px 16px -6px rgba(200,68,44,0.6); }
.nav-item.active svg { filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15)); }
.sidebar-foot { font-size: 10.5px; color: #8A7765; padding: 10px 8px; line-height: 1.5; }

.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; background: rgba(255,255,255,0.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-family: 'Fraunces', serif; font-size: 19px; font-weight: 600; }
.topbar-actions { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 8px; background: var(--cream-2); border: 1px solid var(--line);
  border-radius: 24px; padding: 8px 14px; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink); font-family: inherit;
}
.user-chip-mobile { display: none; padding: 8px; }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 8px); background: white; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 14px 34px -10px rgba(43,27,18,0.2); width: 200px; overflow: hidden; z-index: 60;
}
.user-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; background: none; border: none;
  text-align: left; font-size: 13.5px; cursor: pointer; color: var(--ink); font-family: inherit;
}
.user-menu-item:hover { background: var(--cream-2); }
.user-menu-item.danger { color: var(--terracotta-dark); }
.page-area { flex: 1; padding: 26px 28px 60px; min-width: 0; }

/* ============ STAT CARDS ============ */
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: white; border-radius: var(--radius); padding: 18px 20px; border: 1px solid var(--line);
  position: relative; overflow: hidden; box-shadow: var(--shadow-sm);
  transition: transform .18s, box-shadow .18s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.stat-card.accent-terracotta::before { background: var(--grad-terracotta); }
.stat-card.accent-gold::before { background: var(--gold); }
.stat-card.accent-sage::before { background: var(--sage); }
.stat-card.accent-ink::before { background: var(--ink); }
.stat-card.accent-plum::before { background: var(--plum); }
.stat-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.stat-icon {
  width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.icon-terracotta { background: #FBE9E5; color: var(--terracotta-dark); }
.icon-gold { background: #FBF0DC; color: #97701F; }
.icon-sage { background: #E7EFE5; color: var(--sage); }
.icon-ink { background: var(--cream-2); color: var(--ink); }
.icon-plum { background: #EFE3F1; color: var(--plum); }
.stat-label { font-size: 12px; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-family: 'Fraunces', serif; font-size: 26px; font-weight: 600; margin-top: 8px; word-break: break-word; letter-spacing: -.01em; }
.stat-sub { font-size: 11.5px; color: var(--ink-faint); margin-top: 3px; }

.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; margin-bottom: 20px; }

.card { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }
.card-title { font-family: 'Fraunces', serif; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.link-btn { background: none; border: none; color: var(--terracotta-dark); font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }

.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 170px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar-fill { width: 100%; background: linear-gradient(180deg, var(--gold), var(--terracotta)); border-radius: 6px 6px 0 0; min-height: 4px; transition: height .3s; }
.bar-label { font-size: 11px; color: var(--ink-soft); margin-top: 8px; font-weight: 600; }
.bar-value { font-size: 9.5px; color: var(--ink-faint); margin-top: 2px; white-space: nowrap; }

.alert-list { display: flex; flex-direction: column; gap: 10px; }
.alert-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--cream-2); }
.alert-row:last-child { border-bottom: none; }
.alert-row-info { flex: 1; min-width: 0; }
.alert-row-name { font-size: 13.5px; font-weight: 600; }
.alert-row-cat { font-size: 11.5px; color: var(--ink-faint); }

.prod-thumb { border-radius: 9px; overflow: hidden; background: var(--cream-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: 1px solid var(--line); }
.prod-thumb img { width: 100%; height: 100%; object-fit: cover; }
.prod-thumb svg { color: var(--ink-faint); }

.pill { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 20px; white-space: nowrap; }
.pill-success { background: #E7EFE5; color: var(--sage); }
.pill-warning { background: #FBF0DC; color: #97701F; }
.pill-danger { background: #FBE9E5; color: var(--terracotta-dark); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; padding: 10px 12px; color: var(--ink-soft); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid var(--cream-2); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--cream-2); }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--cream-2); }

.empty-state { padding: 36px 10px; text-align: center; color: var(--ink-faint); font-size: 13.5px; }

/* ============ TOOLBAR / FILTERS ============ */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 20px; }
.search-box { display: flex; align-items: center; gap: 8px; background: white; border: 1px solid var(--line); border-radius: 10px; padding: 10px 13px; min-width: 200px; color: var(--ink-faint); flex: 1; transition: border-color .15s, box-shadow .15s; }
.search-box:focus-within { border-color: var(--terracotta); box-shadow: 0 0 0 3px rgba(200,68,44,0.1); }
.search-box input { border: none; outline: none; background: none; font-size: 14px; color: var(--ink); flex: 1; font-family: inherit; min-width: 0; }
.chip-row { display: flex; gap: 7px; flex-wrap: wrap; }
.chip { background: white; border: 1px solid var(--line); border-radius: 20px; padding: 8px 14px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer; font-family: inherit; white-space: nowrap; transition: background .12s, border-color .12s, color .12s; }
.chip:hover { border-color: var(--terracotta); color: var(--terracotta-dark); }
.chip-active { background: var(--ink); color: white; border-color: var(--ink); }
.chip-active:hover { color: white; }

/* ============ BUTTONS ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-size: 13.5px; font-weight: 600; padding: 11px 18px; border-radius: 10px; cursor: pointer; border: none; transition: filter .15s, background .15s, transform .1s, box-shadow .15s; white-space: nowrap; font-family: inherit; min-height: 42px; }
.btn-primary { background: var(--grad-terracotta); color: white; box-shadow: 0 8px 18px -8px rgba(200,68,44,0.55); }
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 10px 22px -8px rgba(200,68,44,0.65); }
.btn-primary:active { filter: brightness(0.94); transform: translateY(0); }
.btn-ghost { background: var(--cream-2); color: var(--ink); }
.btn-ghost:hover { background: var(--line); }
.btn-ghost-danger { background: #FBE9E5; color: var(--terracotta-dark); }
.btn-ghost-danger:hover { background: #F6D7D0; }
.btn-danger { background: var(--terracotta-dark); color: white; }
.btn-sm { padding: 8px 12px; font-size: 12.5px; min-height: 36px; }
.btn-lg { padding: 15px 18px; font-size: 15px; min-height: 50px; }
.btn-block { width: 100%; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--ink-soft); padding: 6px; display: flex; font-size: 18px; min-height: auto; }
.icon-btn-sm { background: none; border: none; cursor: pointer; color: var(--ink-faint); padding: 6px; display: flex; min-height: auto; }
.icon-btn-sm:hover { color: var(--terracotta-dark); }

/* ============ FORM ============ */
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; font-size: 14.5px; background: white; color: var(--ink); outline: none; font-family: inherit; min-height: 44px; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--terracotta); box-shadow: 0 0 0 3px rgba(200,68,44,0.1); }
.field-row { display: flex; gap: 12px; margin-top: 14px; }
.form-card { padding: 24px; }
.form-grid { display: grid; grid-template-columns: 220px 1fr; gap: 28px; }
.form-col-img { display: flex; flex-direction: column; align-items: center; }
.image-upload {
  width: 100%; aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 14px; background: var(--cream-2);
  display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden;
}
.image-upload img { width: 100%; height: 100%; object-fit: cover; }
.image-upload-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--ink-faint); font-size: 12px; text-align: center; padding: 14px; }

/* ============ PRODUCT GRID ============ */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.product-card { background: white; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s; }
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.product-card-img { aspect-ratio: 4/3; background: var(--cream-2); display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.product-card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.product-card:hover .product-card-img img { transform: scale(1.05); }
.product-card-img svg { color: var(--ink-faint); width: 36px; height: 36px; }
.badge-overlay { position: absolute; top: 8px; left: 8px; font-size: 10px; font-weight: 700; padding: 4px 9px; border-radius: 20px; }
.badge-danger { background: var(--terracotta-dark); color: white; }
.badge-warning { background: var(--gold); color: #45330D; }
.product-card-body { padding: 11px 13px; flex: 1; }
.product-card-cat { font-size: 10.5px; color: var(--ink-faint); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.product-card-name { font-size: 14px; font-weight: 700; margin: 3px 0 8px; line-height: 1.25; }
.product-card-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.product-card-price { font-size: 13.5px; font-weight: 700; }
.product-card-price .unit { font-size: 10.5px; font-weight: 500; color: var(--ink-faint); }
.product-card-actions { display: flex; gap: 8px; padding: 0 13px 13px; }
.product-card-actions .btn { flex: 1; }

/* ============ BILLING LAYOUT ============ */
.billing-layout { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }
.billing-left { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.billing-cat-block { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.billing-cat-title { font-family: 'Fraunces', serif; font-weight: 600; font-size: 15px; color: var(--ink-soft); }

/* Zomato/Swiggy style food-card grid — image on top, full width, content below */
.billing-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.pick-card {
  background: white; border: 1.5px solid var(--line); border-radius: 14px; text-align: left;
  display: flex; flex-direction: column; position: relative; font-family: inherit;
  overflow: hidden; transition: border-color .15s, box-shadow .15s, transform .12s;
  contain: content;
}
.pick-active { border-color: var(--terracotta); box-shadow: 0 0 0 2px rgba(200,68,44,0.12); }
.pick-disabled { opacity: .5; }
.pick-qty-display { transition: color .12s; }

.pick-img-wrap {
  width: 100%; aspect-ratio: 4 / 3; background: var(--cream-2); position: relative; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.pick-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.pick-card:hover .pick-img-wrap img { transform: scale(1.05); }
.pick-img-wrap svg { color: var(--ink-faint); width: 34px; height: 34px; }
.pick-stock-badge {
  position: absolute; top: 7px; left: 7px; font-size: 9.5px; font-weight: 700; padding: 3px 8px;
  border-radius: 20px; letter-spacing: .01em;
}
.pick-stock-badge.low { background: var(--gold); color: #45330D; }
.pick-stock-badge.out { background: var(--terracotta-dark); color: white; }

.pick-body { padding: 10px 11px 11px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.pick-name { font-size: 13px; font-weight: 700; line-height: 1.25; }
.pick-meta-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.pick-price { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.pick-stock-text { font-size: 10px; font-weight: 600; }

.pick-stepper {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 2px;
  background: var(--cream-2); border-radius: 9px; padding: 4px;
}
.pick-stepper-btn {
  width: 30px; height: 30px; border-radius: 7px; border: none; background: white; color: var(--ink);
  font-size: 17px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08); flex-shrink: 0; line-height: 1; font-family: inherit;
}
.pick-stepper-btn:active { transform: scale(0.92); }
.pick-stepper-btn.minus { color: var(--terracotta-dark); }
.pick-stepper-btn.plus { background: var(--terracotta); color: white; }
.pick-stepper-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pick-qty-display { font-weight: 700; font-size: 14px; min-width: 28px; text-align: center; font-family: 'JetBrains Mono', monospace; }
.pick-add-btn {
  width: 100%; background: var(--terracotta); color: white; border: none; border-radius: 9px; padding: 9px;
  font-size: 12.5px; font-weight: 700; cursor: pointer; margin-top: 2px; font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.pick-add-btn:active { filter: brightness(0.92); }
.pick-add-btn:disabled { background: var(--ink-faint); cursor: not-allowed; }

.cart-count-badge {
  background: var(--terracotta); color: white; font-size: 11px; font-weight: 700; border-radius: 20px;
  padding: 2px 8px; margin-left: auto;
}
.billing-right { position: sticky; top: 84px; }
.cart-sheet-close { display: none; margin-left: auto; }
.cart-card { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 110px); }
.cart-head { font-family: 'Fraunces', serif; font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.cart-customer { display: flex; flex-direction: column; }
.cart-items { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1; min-height: 60px; max-height: 280px; padding-right: 2px; }
.cart-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--cream-2); }
.cart-row-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; }
.qty-stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.qty-stepper button { width: 28px; height: 30px; background: var(--cream-2); border: none; cursor: pointer; font-size: 15px; color: var(--ink); font-family: inherit; }
.qty-stepper input { width: 42px; border: none; text-align: center; font-size: 12.5px; outline: none; font-family: inherit; -moz-appearance: textfield; }
.qty-stepper input::-webkit-outer-spin-button, .qty-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cart-row-amt { font-size: 13px; font-weight: 700; width: 64px; text-align: right; flex-shrink: 0; }
.cart-summary { border-top: 1px dashed var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.cart-summary-row { display: flex; align-items: center; justify-content: space-between; font-size: 13.5px; color: var(--ink-soft); gap: 8px; }
.cart-discount-input { width: 90px; padding: 7px 9px; text-align: right; min-height: 38px; }
.cart-total { font-size: 17px; font-weight: 700; color: var(--ink); padding-top: 6px; border-top: 1px solid var(--cream-2); }

.mobile-cart-bar { display: none; }

/* ============ MODAL ============ */
.modal-overlay { position: fixed; inset: 0; background: rgba(43,27,18,0.45); z-index: 100; animation: fadeIn .18s ease; }
.modal-card {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: white; border-radius: 16px; width: calc(100% - 32px); max-width: 440px; overflow: hidden;
  box-shadow: 0 30px 70px -20px rgba(0,0,0,0.35); z-index: 101; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  animation: modalIn .2s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .modal-overlay, .modal-card { animation: none; }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.modal-title { font-family: 'Fraunces', serif; font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.modal-body { padding: 18px 20px 22px; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.return-item-list { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.return-item-list li { display: flex; justify-content: space-between; background: var(--cream-2); padding: 7px 10px; border-radius: 8px; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ============ TOAST ============ */
.toast { position: fixed; bottom: 24px; right: 24px; left: auto; z-index: 200; display: flex; align-items: center; gap: 9px; padding: 13px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 600; box-shadow: 0 14px 34px -10px rgba(0,0,0,0.3); color: white; max-width: calc(100vw - 48px); animation: toastIn .22s cubic-bezier(.2,.9,.3,1.2); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.toast-success { background: var(--sage); }
.toast-error { background: var(--terracotta-dark); }

/* ============ RECEIPT (thermal printer optimized) ============ */
.receipt-page { display: flex; flex-direction: column; align-items: center; gap: 16px; padding-bottom: 40px; }
.receipt-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.receipt-size-toggle { display: flex; gap: 6px; }

.receipt-paper {
  background: white; color: #000;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  box-shadow: 0 10px 40px -15px rgba(43,27,18,0.3);
  padding: 14px 10px;
}
.receipt-paper.receipt-80mm { width: 302px; font-size: 12px; } /* ~80mm at 96dpi-ish scale */
.receipt-paper.receipt-58mm { width: 219px; font-size: 10.5px; } /* ~58mm */

.receipt-logo-row { display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.receipt-logo-row img { width: 40px; height: 40px; }
.receipt-top { text-align: center; }
.receipt-brand { font-weight: 700; font-size: 1.3em; letter-spacing: 0.5px; }
.receipt-sub { font-size: 0.85em; margin-top: 2px; }
.receipt-addr { font-size: 0.78em; margin-top: 4px; line-height: 1.4; }
.receipt-divider { border-top: 1px dashed #000; margin: 8px 0; }
.receipt-divider.solid { border-top: 1px solid #000; }
.receipt-meta { display: flex; flex-direction: column; gap: 2px; font-size: 0.9em; }
.receipt-meta div { display: flex; justify-content: space-between; gap: 8px; }
.receipt-tag { text-align: center; font-weight: 700; font-size: 0.95em; margin: 4px 0; letter-spacing: 1px; }
.receipt-table { width: 100%; font-size: 0.88em; border-collapse: collapse; }
.receipt-table th { text-align: left; padding-bottom: 4px; font-weight: 700; border-bottom: 1px dashed #000; }
.receipt-table th:nth-child(2) { text-align: center; }
.receipt-table th:last-child, .receipt-table td:last-child { text-align: right; }
.receipt-table td { padding: 3px 0; vertical-align: top; }
.receipt-table td:nth-child(2) { text-align: center; }
.receipt-item-name { word-break: break-word; max-width: 110px; }
.receipt-totals { display: flex; flex-direction: column; gap: 3px; font-size: 0.92em; }
.receipt-totals div { display: flex; justify-content: space-between; }
.receipt-grand { font-size: 1.15em; font-weight: 700; padding-top: 5px; border-top: 1px solid #000; margin-top: 3px; }
.receipt-foot { text-align: center; font-size: 0.85em; margin-top: 2px; }
.receipt-foot.small { font-size: 0.72em; opacity: 0.85; margin-top: 6px; }
.receipt-barcode-area { text-align: center; margin-top: 8px; font-size: 0.7em; letter-spacing: 2px; }

@media print {
  .no-print { display: none !important; }
  body { background: white; margin: 0; }
  #app > *:not(#screen-app) { display: none !important; }
  .sidebar, .topbar, .mobile-topbar { display: none !important; }
  .page-area { padding: 0 !important; }
  .receipt-page { padding: 0; gap: 0; align-items: flex-start; }
  .receipt-paper { box-shadow: none; margin: 0; padding: 6px 4px; }
  @page { margin: 0; }
}

/* =========================================================
   RESPONSIVE — TABLET (≤1024px)
   ========================================================= */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .dash-grid { grid-template-columns: 1fr; }
  .billing-layout { grid-template-columns: 1fr 320px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* =========================================================
   RESPONSIVE — MOBILE & SMALL TABLET (≤860px)
   Sidebar becomes a slide-in drawer, topbar simplified
   ========================================================= */
@media (max-width: 860px) {
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    height: var(--mobile-topbar-h); padding: 0 14px; background: var(--ink); color: white;
    position: sticky; top: 0; z-index: 40; flex-shrink: 0;
  }
  .hamburger-btn { background: none; border: none; color: white; padding: 8px; display: flex; cursor: pointer; }
  .mobile-brand { display: flex; align-items: center; gap: 8px; font-family: 'Fraunces', serif; font-weight: 600; font-size: 15px; }
  .mobile-brand-icon { width: 26px; height: 26px; }
  .user-chip-mobile { display: flex; background: rgba(255,255,255,0.12); border: none; color: white; }

  .frame { flex-direction: column; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; transform: translateX(-100%);
    transition: transform .25s ease; box-shadow: 8px 0 30px rgba(0,0,0,0.3); z-index: 70;
    width: min(280px, 82vw);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close-btn { display: flex; background: none; border: none; color: #DCCFC0; position: absolute; right: 0; top: 0; padding: 4px; cursor: pointer; }
  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 65;
  }
  .sidebar-backdrop.show { display: block; }

  .topbar { display: none; }
  .page-area { padding: 16px 14px 90px; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px 14px; }
  .stat-value { font-size: 20px; }

  .billing-layout { grid-template-columns: 1fr; }
  .billing-right { display: none; } /* replaced by slide-up sheet on mobile */
  .billing-right.show-sheet {
    display: block; position: fixed; inset: 0; z-index: 80; background: rgba(43,27,18,0.45);
    top: 0; left: 0; right: 0; bottom: 0;
  }
  .billing-right.show-sheet .cart-card {
    position: fixed; left: 0; right: 0; bottom: 0; top: 10vh; border-radius: 18px 18px 0 0;
    max-height: 90vh; margin: 0;
  }
  .cart-sheet-close { display: flex; }
  .mobile-cart-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    position: fixed; left: 12px; right: 12px; bottom: 14px; z-index: 30;
    background: var(--ink); color: white; border: none; border-radius: 14px; padding: 14px 18px;
    font-size: 13.5px; font-weight: 700; cursor: pointer; box-shadow: 0 10px 30px -8px rgba(0,0,0,0.4); font-family: inherit;
  }
  .mobile-cart-arrow { color: var(--gold); }

  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  /* Tablet (641px-860px): let the grid auto-fit as many cards as comfortably fit */
  .billing-product-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .btn { width: 100%; justify-content: center; }
  .chip-row { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .chip-row::-webkit-scrollbar { display: none; }

  .form-grid { grid-template-columns: 1fr; }
  .form-col-img { max-width: 220px; margin: 0 auto; }

  /* History: hide table, show cards */
  .history-card .table-wrap { display: none; }
  .history-cards { display: flex; flex-direction: column; gap: 10px; padding: 14px; }
  .history-item-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
  .history-item-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
  .history-item-bill { font-weight: 700; font-family: 'JetBrains Mono', monospace; }
  .history-item-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }
  .history-item-actions { display: flex; gap: 8px; margin-top: 10px; }
  .history-item-actions .btn { flex: 1; }
}

@media (min-width: 861px) {
  .history-cards { display: none; }
}

/* =========================================================
   RESPONSIVE — PHONES (≤640px): exactly 2 columns on billing grid
   ========================================================= */
@media (max-width: 640px) {
  .billing-product-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
}

/* =========================================================
   RESPONSIVE — SMALL PHONES (≤480px)
   ========================================================= */
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 18px; }
  .stat-label { font-size: 10.5px; }
  .login-card { padding: 26px 20px; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .billing-product-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .receipt-paper.receipt-80mm { width: 100%; max-width: 302px; }
  .card { padding: 16px; }
  .bar-chart { gap: 5px; }
}

/* =========================================================
   PRINTER CONNECTION UI
   ========================================================= */
.printer-status-bar {
  display: flex; align-items: center; gap: 9px; background: white; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 16px; margin-bottom: 4px; font-size: 13px; color: var(--ink-soft);
  width: 100%; max-width: 380px; flex-wrap: wrap;
}
.printer-status-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--ink-faint); flex-shrink: 0;
}
.printer-status-dot.connected { background: var(--sage); box-shadow: 0 0 0 3px rgba(92,122,92,0.18); }
.printer-status-dot.error { background: var(--terracotta-dark); }
#printer-status-text { flex: 1; font-weight: 600; }

.printer-current-status {
  display: flex; align-items: center; gap: 9px; background: var(--cream-2); border-radius: 10px;
  padding: 11px 14px; margin-bottom: 16px; font-size: 13px; font-weight: 600; color: var(--ink);
}
.printer-option-tabs { display: flex; gap: 6px; margin-bottom: 16px; background: var(--cream-2); padding: 4px; border-radius: 10px; }
.printer-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 10px;
  border: none; background: none; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-soft);
  cursor: pointer; font-family: inherit;
}
.printer-tab.active { background: white; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.printer-help-text { font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; margin: 0 0 14px; }
.printer-help-text code { background: var(--cream-2); padding: 1px 6px; border-radius: 5px; font-family: 'JetBrains Mono', monospace; }
.printer-panel { display: flex; flex-direction: column; }

/* =========================================================
   DEVELOPER CREDIT
   ========================================================= */
.dev-credit { color: #8A7765; font-size: 10px; }
.login-dev-credit { margin-top: 10px; font-size: 11px; color: var(--ink-faint); text-align: center; }



/* ================================
   FIX: Mobile Category Chips Scroll
   Add at end of style.css
================================ */

@media (max-width:860px){

    .toolbar{
        display:flex !important;
        flex-direction:column !important;
        align-items:stretch !important;
        gap:12px;
    }

    .toolbar .search-box{
        width:100% !important;
        flex:none !important;
    }

    #billing-cat-chips,
    #product-cat-chips,
    #history-status-chips{
        display:flex !important;
        flex-wrap:nowrap !important;
        overflow-x:auto !important;
        overflow-y:hidden !important;
        width:100% !important;
        white-space:nowrap !important;
        gap:8px !important;
        padding-bottom:6px;
        -webkit-overflow-scrolling:touch;
        scrollbar-width:none;
        scroll-behavior:smooth;
    }

    #billing-cat-chips::-webkit-scrollbar,
    #product-cat-chips::-webkit-scrollbar,
    #history-status-chips::-webkit-scrollbar{
        display:none;
    }

    #billing-cat-chips .chip,
    #product-cat-chips .chip,
    #history-status-chips .chip{
        flex:0 0 auto !important;
    }

}

html,
body{
    width:100%;
    overflow-x:hidden;
}

.page-area,
.page,
.card,
.toolbar,
.billing-layout,
.billing-product-grid{
    min-width:0;
    max-width:100%;
}

img,
table,
input,
select,
button{
    max-width:100%;
}

/* ================================
   FIX: iPhone / Small Mobile — New Bill Page
   - Product card names not truncating
   - Images showing correctly
   - Cart sheet safe area padding
================================ */

@media (max-width: 640px) {

  /* Product card: ensure image takes full width at proper ratio */
  .pick-img-wrap {
    aspect-ratio: 1 / 1; /* Square on small screens — more visible */
  }

  /* Product name: allow wrapping, no truncation */
  .pick-name {
    font-size: 12px;
    white-space: normal !important;
    word-break: break-word;
    overflow: visible !important;
    text-overflow: unset !important;
    display: block !important;
    -webkit-line-clamp: unset !important;
  }

  /* Slightly reduce card body padding on small screens */
  .pick-body {
    padding: 8px 9px 10px;
    gap: 4px;
  }

  /* Add + button font size */
  .pick-add-btn {
    font-size: 12px;
    padding: 8px;
  }

  /* Stepper buttons — easier to tap */
  .pick-stepper-btn {
    width: 28px;
    height: 28px;
  }

  /* Grid: ensure 2 columns fit well on all iPhones */
  .billing-product-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  /* Page area bottom padding: enough space above mobile cart bar */
  .page-area {
    padding-bottom: 100px !important;
  }

  /* Cart bar: respect iPhone home indicator (safe area) */
  .mobile-cart-bar {
    bottom: max(14px, env(safe-area-inset-bottom, 14px));
  }

  /* Cart sheet: respect notch/home area */
  .billing-right.show-sheet .cart-card {
    padding-bottom: max(18px, env(safe-area-inset-bottom, 18px));
  }
}
/* ============ ROLE BADGE (topbar user chip) ============ */
.role-badge {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: 2px 8px; border-radius: 20px; margin-left: 2px;
}
.role-badge-admin { background: #EFE3F1; color: var(--plum); }
.role-badge-manager { background: #E7EFE5; color: var(--sage); }

/* ============ MANAGERS / STAFF PAGE ============ */
.manager-card {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: white; margin-bottom: 10px; box-shadow: var(--shadow-sm);
}
.manager-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--grad-terracotta); color: white;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.manager-info { flex: 1; min-width: 0; }
.manager-name { font-weight: 700; font-size: 14px; }
.manager-meta { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.manager-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ============ PERMISSION NOTICE (manager restricted areas) ============ */
.permission-notice {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
  padding: 60px 20px; color: var(--ink-soft);
}
.permission-notice svg { color: var(--ink-faint); }
