:root {
  --bg: #f5f6f5;
  --bg-elevated: #ffffff;
  --ink: #18241e;
  --ink-muted: #5f6d65;
  --line: #e2e7e4;
  --brand: #1f6f43;
  --brand-dark: #185835;
  --brand-sidebar: #163a28;
  --brand-sidebar-active: #23523a;
  --brand-soft: #ebf3ee;
  --brand-border: #94bfa7;
  --brand-gold: #e5cf68;
  --accent: #1f6f43;
  --ok: #1f6f43;
  --warn: #b45309;
  --danger: #b91c1c;
  --shadow: 0 4px 16px rgba(22, 58, 40, 0.05);
  --radius: 16px;
  --nav-h: 64px;
  --bottom-h: 72px;
  --sidebar-w: 248px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }
img { max-width: 100%; display: block; }

.app-shell {
  min-height: 100%;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.25rem 1rem;
  background: var(--brand-sidebar);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.brand {
  padding: 0.85rem 0.65rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,0.14);
}
.brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
}
.brand-logo {
  width: 100%;
  max-width: 210px;
  height: auto;
  aspect-ratio: 2.2 / 1;
  border-radius: 12px;
  object-fit: contain;
  background: #019034;
  border: 1px solid rgba(255,255,255,0.14);
  flex-shrink: 0;
  display: block;
}
.brand-logo--sm {
  width: 92px;
  height: auto;
  aspect-ratio: 2.2 / 1;
  border-radius: 8px;
  object-fit: contain;
  background: #019034;
  border: 1px solid rgba(255,255,255,0.14);
  display: inline-block;
  vertical-align: middle;
  margin-right: 0;
}
.sidebar-foot {
  display: grid;
  gap: 0.65rem;
  margin-top: auto;
}
.sidebar-foot .btn-ghost {
  color: #e6f0ea !important;
  border-color: rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
}
.sidebar-foot .btn-ghost:hover {
  background: rgba(255,255,255,0.12);
}
.brand-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.brand-sub {
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: #b8cec1;
  opacity: 0.95;
}

.nav-list { display: flex; flex-direction: column; gap: 0.35rem; flex: 1; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  color: #c5d8cd;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; transform: translateX(2px); }
.nav-link.active { background: var(--brand-sidebar-active); color: #fff; font-weight: 650; box-shadow: inset 3px 0 0 var(--brand-gold); }
.nav-ico { width: 1.25rem; text-align: center; opacity: 0.9; }

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}

.content {
  padding: 1.25rem;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
  flex: 1;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad { padding: 1.1rem 1.2rem; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}
.kpi {
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 0.45s ease both;
}
.kpi:nth-child(2) { animation-delay: 0.05s; }
.kpi:nth-child(3) { animation-delay: 0.1s; }
.kpi:nth-child(4) { animation-delay: 0.15s; }
.kpi-label { font-size: 0.78rem; color: var(--ink-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { margin-top: 0.35rem; font-size: 1.45rem; font-weight: 700; letter-spacing: -0.03em; }
.kpi-hint { margin-top: 0.25rem; font-size: 0.8rem; color: var(--ink-muted); }

.grid-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.section-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 42px;
  padding: 0.55rem 1rem;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: scale(0.98); }
.btn-ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover { background: #f8fafc; }
.btn-danger { background: var(--danger); }
.btn-sm { min-height: 34px; padding: 0.35rem 0.7rem; font-size: 0.85rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-icon {
  width: 42px; height: 42px; padding: 0; border-radius: 12px;
}

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-size: 0.8rem; font-weight: 650; color: var(--ink-muted); }
.input, .select, .textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.4rem;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 1rem 1rem;
  cursor: pointer;
}
.select::-ms-expand { display: none; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 111, 67, 0.14);
}
.textarea { min-height: 90px; resize: vertical; }

.table-wrap { overflow: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.data th, table.data td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
table.data th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  background: #f8fafc;
}
table.data tr:hover td { background: #f8fafc; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-partial { background: #fef3c7; color: #92400e; }
.badge-credit { background: #fee2e2; color: #991b1b; }
.badge-muted { background: #e2e8f0; color: #334155; }

.flash-wrap { display: grid; gap: 0.5rem; margin-bottom: 1rem; }
.flash {
  padding: 0.8rem 1rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
}
.flash-success { background: #d1fae5; color: #065f46; }
.flash-error { background: #fee2e2; color: #991b1b; }

/* Mobile bottom nav */
.mobile-top {
  display: none;
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  padding: 0 1rem;
  align-items: center;
  justify-content: space-between;
  background: var(--brand-sidebar);
  color: #fff;
}
.mobile-brand {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  min-height: 2rem;
}
.mobile-brand .brand-logo--sm {
  margin-right: 0;
}

.bottom-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  height: calc(var(--bottom-h) + env(safe-area-inset-bottom));
  padding: 0.4rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
  grid-template-columns: repeat(5, 1fr);
  gap: 0.15rem;
}
.bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  border-radius: 12px;
  color: var(--ink-muted);
  font-size: 0.65rem;
  font-weight: 650;
}
.bn-item.active { color: var(--brand); background: var(--brand-soft); }
.bn-ico { font-size: 1.15rem; line-height: 1; }

/* POS */
.pos-layout {
  display: grid;
  grid-template-columns: 1.35fr 0.95fr;
  gap: 1rem;
  min-height: calc(100vh - var(--nav-h) - 2.5rem);
}
.pos-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}
.price-tabs, .pay-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.chip {
  min-height: 38px;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 650;
  cursor: pointer;
}
.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.pay-add {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1.5px dashed #94a3b8;
  background: #fff;
  color: #475569;
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding-right: 0.2rem;
}
.product-tile {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 0.85rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  text-align: left;
}
.product-tile:hover {
  transform: translateY(-2px);
  border-color: var(--brand-border);
  box-shadow: var(--shadow);
}
.product-tile.is-low { border-color: #fcd34d; }
.product-tile.is-out { opacity: 0.55; border-color: #fecaca; cursor: not-allowed; }
.product-tile:disabled {
  pointer-events: none;
  opacity: 0.5;
}
.pos-toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translate(-50%, -120%);
  z-index: 90;
  width: min(520px, calc(100vw - 2rem));
  padding: 0.85rem 1.1rem;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.pos-toast.show { opacity: 1; transform: translate(-50%, 0); }
.pos-toast.error { background: #b91c1c; }

#change-row { color: var(--ink-muted); }
#change-row.has-change {
  color: var(--ok);
  font-weight: 800;
}

.status-pay-btn {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
}
.status-pay-btn:hover .badge {
  outline: 2px solid rgba(15, 118, 110, 0.35);
  outline-offset: 2px;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: #334155;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
  padding: 0;
}
.icon-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}
.icon-btn:hover {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand-dark);
}
.icon-btn.danger:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}
.icon-btn.primary:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-dark);
}

.category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.category-row:last-child { border-bottom: 0; }
.category-meta { min-width: 0; }
.category-meta .name { font-weight: 700; font-size: 0.92rem; }
.category-meta .sub { font-size: 0.72rem; color: var(--ink-muted); margin-top: 0.1rem; }

.cat-manage-grid {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 1rem;
  align-items: start;
}
.cat-manage-grid .dash-feed-item.category-row {
  display: block;
  padding: 0.85rem 1.15rem;
  border-bottom: 0;
}
.cat-manage-grid .dash-feed-aside {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
}

@media (max-width: 860px) {
  .cat-manage-grid { grid-template-columns: 1fr; }
}

/* Product form → Buy & sell units */
.unit-matrix-title {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--ink-muted);
}
.unit-matrix .section-head {
  align-items: flex-start;
  margin-bottom: 0.65rem;
}
.unit-matrix .section-head .btn {
  margin-top: 0.1rem;
  flex-shrink: 0;
}
.unit-matrix-head,
.unit-matrix-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.15fr) minmax(85px, 0.75fr) 74px repeat(3, minmax(95px, 1fr)) 40px;
  gap: 0.55rem;
  align-items: center;
}
.unit-matrix-head {
  padding: 0 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--line);
}
.unit-matrix-rows {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.unit-matrix-row {
  min-width: 0;
}
.unit-matrix-cell {
  min-width: 0;
}
.unit-matrix-lbl {
  display: none;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin-bottom: 0.2rem;
}
.unit-matrix-base {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  min-height: 42px;
  font-size: 0.85rem;
  font-weight: 650;
  white-space: nowrap;
}
.unit-matrix-row .icon-btn {
  width: 42px;
  height: 42px;
  justify-self: center;
}
.price-unit-head,
.price-unit-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.1fr) repeat(3, minmax(90px, 1fr));
  gap: 0.55rem;
  align-items: center;
}
.price-unit-head {
  padding: 0 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--line);
}
.price-unit-row {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}
.price-unit-row:last-child { border-bottom: 0; }
.price-unit-cell { min-width: 0; }
@media (max-width: 820px) {
  .unit-matrix-head { display: none; }
  .unit-matrix-lbl { display: block; }
  .unit-matrix-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "unit unit rm"
      "qty base base"
      "retail wholesale ice";
    padding: 0.65rem;
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    background: #f8fafc;
  }
  .unit-matrix-row .cell-unit { grid-area: unit; }
  .unit-matrix-row .cell-qty { grid-area: qty; }
  .unit-matrix-row .cell-base { grid-area: base; }
  .unit-matrix-row .cell-retail { grid-area: retail; }
  .unit-matrix-row .cell-wholesale { grid-area: wholesale; }
  .unit-matrix-row .cell-ice { grid-area: ice; }
  .unit-matrix-row .matrix-remove { grid-area: rm; justify-self: end; align-self: end; }
}
@media (max-width: 640px) {
  .price-unit-head { display: none; }
  .price-unit-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 0.6rem;
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    background: #f8fafc;
  }
  .price-unit-meta { grid-column: 1 / -1; }
}

/* Settings → Units list */
.unit-list-head,
.unit-list-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.5fr) minmax(100px, 0.8fr) 56px 76px 40px;
  gap: 0.6rem;
  align-items: center;
}
.unit-list-head {
  padding: 0 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--line);
}
.unit-list-row {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}
.unit-list-row:last-child { border-bottom: 0; }
.unit-list-form {
  display: contents;
}
.unit-list-del {
  display: flex;
  align-items: center;
  justify-content: center;
}
.unit-active {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  height: 42px;
}
.unit-add-form {
  display: grid;
  grid-template-columns: minmax(140px, 1.5fr) minmax(100px, 0.8fr) auto;
  gap: 0.75rem;
  align-items: end;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
@media (max-width: 640px) {
  .unit-list-head { display: none; }
  .unit-list-row {
    grid-template-columns: 1fr 1fr auto;
    grid-template-areas:
      "name name name"
      "symbol active del"
      "save save save";
  }
  .unit-list-form input[name="name"] { grid-area: name; }
  .unit-list-form input[name="symbol"] { grid-area: symbol; }
  .unit-list-form .unit-active { grid-area: active; height: auto; justify-content: flex-start; }
  .unit-list-form .btn { grid-area: save; width: 100%; }
  .unit-list-del { grid-area: del; }
  .unit-add-form { grid-template-columns: 1fr; }
}

@media print {
  body.printing-receipt {
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    background: #fff !important;
  }
  body.printing-receipt .mobile-top,
  body.printing-receipt .bottom-nav,
  body.printing-receipt .sidebar,
  body.printing-receipt .topbar,
  body.printing-receipt .flash-wrap,
  body.printing-receipt #pos-toast,
  body.printing-receipt #pos-app,
  body.printing-receipt #unit-pick-modal,
  body.printing-receipt #scan-modal {
    display: none !important;
  }
  body.printing-receipt .app-shell,
  body.printing-receipt .main,
  body.printing-receipt .content {
    display: block !important;
    width: auto !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: transparent !important;
  }
  body.printing-receipt #receipt-modal {
    display: block !important;
    position: static !important;
    inset: auto !important;
    width: 76mm !important;
    max-width: 76mm !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }
  body.printing-receipt #receipt-modal > div {
    display: block !important;
    width: 76mm !important;
    max-width: 76mm !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }
  body.printing-receipt #receipt-modal .no-print { display: none !important; }
  body.printing-receipt #receipt-modal-body {
    display: block !important;
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  body.printing-receipt .receipt-sheet {
    width: 76mm;
    max-width: 76mm;
    margin: 0;
    padding: 0;
    color: #000;
    font-size: 12px;
    line-height: 1.35;
  }
}
.product-tile .name { font-weight: 700; font-size: 0.92rem; line-height: 1.25; }
.product-tile .meta { margin-top: 0.35rem; font-size: 0.75rem; color: var(--ink-muted); }
.product-tile .price { margin-top: 0.55rem; font-weight: 800; color: var(--brand-dark); }

.cart-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.cart-items {
  flex: 1;
  overflow: auto;
  max-height: 42vh;
}
.cart-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}
.cart-line .qty-ctrl {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.cart-line .cart-unit,
.select.select-sm {
  min-height: 34px;
  padding: 0.3rem 2rem 0.3rem 0.6rem;
  font-size: 0.8rem;
  border-radius: 10px;
  background-position: right 0.55rem center;
}
.input.input-sm {
  min-height: 34px;
  padding: 0.3rem 0.55rem;
  font-size: 0.82rem;
  border-radius: 10px;
}
.po-line-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}
.po-cost-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.po-cost-input {
  width: 96px;
}
.po-qty-input {
  width: 64px;
  text-align: center;
  font-weight: 700;
}
.qty-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
  cursor: pointer;
  font-weight: 700;
}
.cart-totals { margin-top: auto; padding-top: 0.85rem; display: grid; gap: 0.45rem; }
.total-row { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.95rem; }
.total-row.grand { font-size: 1.2rem; font-weight: 800; }
.mixed-box {
  display: none;
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  gap: 0.5rem;
}
.mixed-box.show { display: grid; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(400px, 100%);
  padding: 2rem 1.75rem 1.5rem;
  border-radius: 22px;
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 0.5s ease;
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 0.15rem 0 1.35rem;
}
.login-logo {
  width: min(260px, 88%);
  height: auto;
  aspect-ratio: 2.2 / 1;
  border-radius: 16px;
  object-fit: contain;
  background: #019034;
  margin: 0;
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(22, 58, 40, 0.14);
  display: block;
}
.login-eyebrow {
  margin: 0 0 0.45rem;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
  line-height: 1.2;
}
.login-card h1 {
  font-family: var(--font-display);
  margin: 0;
  font-size: 1.85rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.login-tagline {
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
  line-height: 1.35;
}
.login-form {
  display: grid;
  gap: 0.95rem;
}
.login-form .field {
  width: 100%;
  text-align: left;
}
.password-field {
  position: relative;
}
.password-field .input {
  padding-right: 2.75rem;
}
.password-toggle {
  position: absolute;
  right: 0.3rem;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
}
.password-toggle:hover {
  color: var(--ink);
  background: var(--brand-soft);
}
.password-toggle svg {
  width: 18px;
  height: 18px;
  display: block;
}
.password-toggle .icon-eye-off { display: none; }
.password-toggle.is-visible .icon-eye { display: none; }
.password-toggle.is-visible .icon-eye-off { display: block; }
.login-form .btn {
  margin-top: 0.25rem;
}
.login-foot {
  margin: 1.15rem 0 0;
  text-align: center;
}
.muted { color: var(--ink-muted); }
.tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.tab {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 650;
  font-size: 0.85rem;
}
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ink-muted);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .pos-layout { grid-template-columns: 1fr; }
  .product-grid { max-height: 38vh; }
}

@media (max-width: 860px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .mobile-top, .bottom-nav { display: grid; }
  .bottom-nav { display: grid; }
  .content {
    padding: 1rem;
    padding-bottom: calc(var(--bottom-h) + 1rem + env(safe-area-inset-bottom));
  }
  .topbar { display: none; }
  .pos-layout { min-height: auto; }
  .cart-panel {
    position: sticky;
    bottom: calc(var(--bottom-h) + 0.5rem);
    z-index: 20;
  }
}

/* Language switcher */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.18rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
}
.lang-btn {
  min-width: 2.4rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  text-align: center;
}
.lang-btn.is-active {
  background: var(--ink);
  color: #fff;
}
.lang-switch--sidebar {
  width: 100%;
  justify-content: stretch;
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.14);
}
.lang-switch--sidebar .lang-btn {
  flex: 1;
  color: #c5d8cd;
}
.lang-switch--sidebar .lang-btn.is-active {
  background: var(--brand-sidebar-active);
  color: #fff;
}
.lang-switch--login {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 20;
  box-shadow: var(--shadow);
}
.lang-switch--compact {
  background: rgba(0, 0, 0, 0.18);
  border-color: rgba(255,255,255,0.18);
}
.lang-switch--compact .lang-btn { color: #c5d8cd; }
.lang-switch--compact .lang-btn.is-active {
  background: #ffffff;
  color: var(--brand-sidebar);
}

.logo-upload {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}
.logo-upload-meta { min-width: 0; flex: 1; }
.logo-preview {
  width: 152px;
  height: 76px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #019034;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: 800;
  font-size: 1.5rem;
  color: #ffffff;
  position: relative;
  padding: 0;
}
.logo-preview--btn {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.logo-preview--btn:hover {
  transform: translateY(-1px);
  border-color: var(--brand-border);
  box-shadow: 0 0 0 3px rgba(31, 111, 67, 0.14);
}
.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.logo-preview-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.45);
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.logo-preview--btn:hover .logo-preview-overlay,
.logo-preview--btn:focus-visible .logo-preview-overlay {
  opacity: 1;
}
.logo-preview-overlay svg {
  width: 22px;
  height: 22px;
}

.translation-table .input {
  min-height: 38px;
  padding: 0.4rem 0.65rem;
  font-size: 0.9rem;
}
.translation-key code {
  font-size: 0.75rem;
  color: var(--ink-muted);
  word-break: break-all;
}
.translation-group {
  background: #f8fafc;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  padding-top: 0.75rem !important;
  padding-bottom: 0.75rem !important;
}

.lang-picks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
.lang-pick {
  display: grid;
  gap: 0.25rem;
  justify-items: start;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.lang-pick input { position: absolute; opacity: 0; pointer-events: none; }
.lang-pick.is-active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}
.lang-pick-code {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
}
.lang-pick-name {
  font-size: 0.8rem;
  color: var(--ink-muted);
  font-weight: 600;
}

body.lang-mm {
  font-family: "Noto Sans Myanmar", "Manrope", system-ui, sans-serif;
}

/* ── Dashboard layout ── */
.dash-bento {
  display: grid;
  grid-template-columns: 1.55fr 0.95fr 1fr;
  grid-template-areas:
    "hero alert inv"
    "hero alert exp";
  gap: 0.9rem;
}
.dash-hero { grid-area: hero; }
.dash-alert-card { grid-area: alert; }
.dash-inv { grid-area: inv; }
.dash-exp { grid-area: exp; }

.dash-hero {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.25rem 1.35rem;
  background:
    radial-gradient(ellipse 80% 70% at 100% 0%, rgba(229, 207, 104, 0.18), transparent 55%),
    linear-gradient(145deg, #1f6f43 0%, #163a28 100%);
  border: none;
  color: #fff;
  box-shadow: 0 10px 28px rgba(22, 58, 40, 0.22);
}
.dash-hero .kpi-label { color: rgba(255, 255, 255, 0.72); }
.dash-hero .kpi-hint { color: rgba(255, 255, 255, 0.68); }
.dash-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.dash-hero-value {
  margin-top: 0.35rem;
  font-size: clamp(1.85rem, 2.6vw, 2.45rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
}
.dash-hero-mark {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--brand-gold);
  font-size: 1.1rem;
  flex-shrink: 0;
}
.dash-split {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}
.dash-split-item {
  display: grid;
  gap: 0.2rem;
  padding: 0.7rem 0.75rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  min-width: 0;
}
.dash-split-label {
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.62);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-split-value {
  font-size: 0.95rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: #fff;
}
.dash-split-value.text-ok { color: #b7f0cb; }
.dash-split-value.text-warn { color: #ffe0a3; }

.dash-alert-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.15rem 1.2rem;
  min-height: 100%;
}
.dash-alert-card--ok {
  background: linear-gradient(180deg, #f3faf6 0%, #fff 55%);
  border-color: var(--brand-border);
}
.dash-alert-card--warn {
  background: linear-gradient(180deg, #fff8eb 0%, #fff 60%);
  border-color: #f0d4a0;
}
.dash-alert-card--danger {
  background: linear-gradient(180deg, #fff1f1 0%, #fff 60%);
  border-color: #f0b4b4;
}
.dash-alert-value {
  font-size: clamp(2rem, 3vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--ink);
}
.dash-alert-card--warn .dash-alert-value { color: var(--warn); }
.dash-alert-card--danger .dash-alert-value { color: var(--danger); }
.dash-alert-meta { margin-top: 0.35rem; }
.dash-alert-link {
  margin-top: auto;
  padding-top: 0.85rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--brand-dark);
}

.dash-side {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}

.dash-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}
.dash-pill--muted { background: #eef2f0; color: var(--ink-muted); }
.dash-pill--ok { background: #d9f2e4; color: #065f46; }
.dash-pill--warn { background: #fef3c7; color: #92400e; }
.dash-pill--danger { background: #fee2e2; color: #991b1b; }

.dash-mid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1rem;
  align-items: stretch;
}
.dash-chart-card,
.dash-rank-card {
  min-height: 280px;
}
.dash-soft-meta {
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--ink-muted);
}

.dash-bars {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.55rem;
  align-items: end;
  min-height: 210px;
  padding-top: 0.35rem;
}
.dash-bar {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  justify-items: center;
  gap: 0.35rem;
  min-width: 0;
  height: 210px;
}
.dash-bar-amount {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--ink-muted);
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-bar-track {
  width: 100%;
  max-width: 42px;
  align-self: stretch;
  border-radius: 999px;
  background: #eef2f0;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}
.dash-bar-fill {
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(180deg, #2f8f58 0%, var(--brand-dark) 100%);
  min-height: 8px;
  transition: height 0.35s ease;
}
.dash-bar.is-today .dash-bar-fill {
  background: linear-gradient(180deg, var(--brand-gold) 0%, #c9ad3d 100%);
}
.dash-bar.is-today .dash-bar-day { color: var(--brand-dark); font-weight: 800; }
.dash-bar-day {
  font-size: 0.75rem;
  font-weight: 750;
  color: var(--ink);
}
.dash-bar-date {
  font-size: 0.65rem;
  color: var(--ink-muted);
  font-weight: 600;
}

.dash-rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}
.dash-rank-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  align-items: start;
}
.dash-rank-num {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 800;
  background: #f1f5f3;
  color: var(--ink-muted);
  flex-shrink: 0;
}
.dash-rank-num.is-top {
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.dash-rank-body { min-width: 0; }
.dash-rank-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.dash-rank-name {
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-rank-sub {
  margin-top: 0.1rem;
  font-size: 0.75rem;
  color: var(--ink-muted);
}
.dash-rank-rev {
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: -0.02em;
}
.dash-rank-meter {
  margin-top: 0.4rem;
  height: 5px;
  border-radius: 999px;
  background: #eef2f0;
  overflow: hidden;
}
.dash-rank-meter > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand) 0%, #2f8f58 100%);
}

.dash-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.dash-panel { overflow: hidden; }
.dash-link {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--brand-dark);
}
.dash-link:hover { text-decoration: underline; }

.dash-feed {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0 0.35rem;
}
.dash-feed-item {
  padding: 0.85rem 1.15rem;
  border-top: 1px solid var(--line);
}
.dash-feed-item:first-child { border-top: none; }
.dash-feed-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
}
.dash-feed-title {
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.3;
}
.dash-feed-sub {
  margin-top: 0.15rem;
  font-size: 0.75rem;
  color: var(--ink-muted);
}
.dash-feed-aside {
  display: grid;
  justify-items: end;
  gap: 0.3rem;
  flex-shrink: 0;
}
.dash-feed-foot {
  margin-top: 0.45rem;
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-weight: 600;
}
.dash-stock-qty {
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.dash-stock-qty--warn { color: var(--warn); }
.dash-stock-qty--danger { color: var(--danger); }
.dash-stock-meter {
  margin-top: 0.55rem;
  height: 6px;
  border-radius: 999px;
  background: #eef2f0;
  overflow: hidden;
}
.dash-stock-meter-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
}
.dash-stock-meter-fill--warn { background: #d97706; }
.dash-stock-meter-fill--danger {
  background: repeating-linear-gradient(
    -45deg,
    rgba(185, 28, 28, 0.35),
    rgba(185, 28, 28, 0.35) 4px,
    rgba(185, 28, 28, 0.12) 4px,
    rgba(185, 28, 28, 0.12) 8px
  );
  width: 100% !important;
}

.dash-sale-total {
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}
.dash-sale-item:hover {
  background: #f7faf8;
}

@media (max-width: 1180px) {
  .dash-bento {
    grid-template-columns: 1.4fr 1fr;
    grid-template-areas:
      "hero hero"
      "alert inv"
      "alert exp";
  }
  .dash-split { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
  .dash-mid,
  .dash-bottom { grid-template-columns: 1fr; }
  .dash-chart-card,
  .dash-rank-card { min-height: 0; }
}

@media (max-width: 720px) {
  .dash-bento {
    grid-template-columns: 1fr;
    grid-template-areas:
      "hero"
      "alert"
      "inv"
      "exp";
  }
  .dash-split { grid-template-columns: 1fr; }
  .dash-bars {
    gap: 0.35rem;
    min-height: 180px;
  }
  .dash-bar { height: 180px; }
  .dash-bar-amount { font-size: 0.55rem; }
  .dash-feed-main { flex-direction: column; }
  .dash-feed-aside { justify-items: start; }
}

@media print {
  @page {
    size: 80mm auto;
    margin: 2mm;
  }
  html, body { height: auto !important; min-height: 0 !important; }
  body { background: #fff; }
  .sidebar, .topbar, .mobile-top, .bottom-nav, .no-print { display: none !important; }
  .app-shell, .main, .content { display: block; padding: 0; margin: 0; }
}
