:root {
  --duqqa: #4f2015;
  --smoky: #140f09;
  --silent: #dbd8ce;
  --primer: #c4bdab;
  --grove: #917d5e;
  --iroko: #42331d;
  --paper: #faf8f2;
  --paper-2: #f2eee6;
  --line: #ded7ca;
  --muted: #756e65;
  --text: #241b15;
  --danger: #9a3428;
  --ok: #277453;
  --shadow: 0 18px 50px rgba(35, 28, 23, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 54% 7%, rgba(145, 125, 94, 0.16), transparent 32%), var(--paper);
  color: var(--text);
  font-family: "Noto Sans Thai", "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 14px;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.login-screen {
  display: grid;
  grid-template-columns: 420px minmax(560px, 1fr);
  min-height: 100vh;
}

.login-brand {
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 32px;
  background: linear-gradient(180deg, rgba(79, 32, 21, 0.98), rgba(20, 15, 9, 0.98));
  color: #f4eee4;
}

.login-brand img {
  width: min(100%, 390px);
  height: auto;
  object-fit: contain;
}

.login-brand p {
  margin-top: 16px;
  color: rgba(244, 238, 228, 0.72);
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

.login-panel {
  display: grid;
  align-content: center;
  max-width: 520px;
  padding: 56px;
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: 34px;
  font-weight: 500;
}

.login-panel > p {
  margin: 0 0 28px;
  color: var(--muted);
  line-height: 1.6;
}

.form-row {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.form-row label,
.control-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.form-row input,
.form-row select,
.field,
.select {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 249, 0.86);
  color: var(--text);
}

.readonly-field {
  display: grid;
  align-items: center;
}

.primary,
.secondary {
  min-height: 40px;
  border-radius: 6px;
  font-weight: 800;
}

.compact {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.primary {
  border: 1px solid var(--duqqa);
  background: var(--duqqa);
  color: white;
}

.secondary {
  border: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.72);
  color: var(--iroko);
}

.danger {
  min-height: 40px;
  border: 1px solid rgba(154, 52, 40, 0.28);
  border-radius: 6px;
  background: rgba(154, 52, 40, 0.08);
  color: var(--danger);
  font-weight: 800;
}

.primary:disabled,
.secondary:disabled,
.danger:disabled,
.product-card:disabled,
.stepper button:disabled,
.remove:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.demo-logins {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.demo-logins button {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-2);
  color: var(--iroko);
}

.app-shell {
  display: grid;
  grid-template-columns: 196px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 28px 18px 20px;
  background: linear-gradient(180deg, rgba(79, 32, 21, 0.98), rgba(20, 15, 9, 0.98));
  color: #f4eee4;
}

.brand {
  display: grid;
  justify-items: center;
  padding-bottom: 28px;
  border-bottom: 1px solid rgba(219, 216, 206, 0.2);
}

.brand img {
  width: 108px;
  height: 100px;
  object-fit: cover;
  object-position: 50% 22%;
}

.side-nav {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 14px;
  min-height: 0;
  padding-top: 24px;
  overflow: auto;
}

.nav-group {
  display: grid;
  gap: 6px;
}

.nav-group-label {
  padding: 0 16px;
  color: rgba(244, 238, 228, 0.58);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.side-nav button,
.logout,
.sidebar .install-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #f8f0e6;
  padding: 0 16px;
  text-align: left;
}

.side-nav button.active,
.side-nav button:hover {
  background: rgba(145, 125, 94, 0.28);
}

.side-nav button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.user-card {
  margin-top: 14px;
  padding: 14px 10px;
  border: 1px solid rgba(219, 216, 206, 0.26);
  border-radius: 7px;
}

.user-card strong,
.user-card span {
  display: block;
}

.user-card span {
  color: rgba(244, 238, 228, 0.68);
  font-size: 11px;
}

.logout {
  margin-top: 14px;
  border-color: rgba(219, 216, 206, 0.25);
  text-align: center;
}

.sidebar .install-button {
  margin-top: 14px;
  border-color: rgba(219, 216, 206, 0.35);
  background: rgba(244, 238, 228, 0.08);
  font-weight: 800;
  text-align: center;
}

.login-install {
  margin-top: 10px;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 250px 250px auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 22px;
}

.page-title h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 500;
}

.page-title p {
  margin: 0;
  color: var(--grove);
  letter-spacing: 0.28em;
}

.switcher {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  height: 40px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.switcher button {
  border: 0;
  background: rgba(255, 253, 249, 0.7);
  color: var(--muted);
}

.switcher button.active {
  background: var(--duqqa);
  color: white;
}

.pos-layout {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) 360px;
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 253, 249, 0.78);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 190px 132px 90px;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.scan-field {
  border-color: rgba(79, 32, 21, 0.42);
  box-shadow: inset 0 0 0 1px rgba(79, 32, 21, 0.12);
}

.category-tabs {
  display: flex;
  gap: 20px;
  padding: 0 18px 12px;
  border-bottom: 1px solid var(--line);
}

.category-tabs button {
  min-height: 34px;
  padding: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
}

.category-tabs button.active {
  border-color: var(--duqqa);
  color: var(--duqqa);
  font-weight: 800;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  max-height: calc(100vh - 238px);
  padding: 18px;
  overflow: auto;
}

.product-card {
  position: relative;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf9;
  text-align: left;
  overflow: hidden;
}

.product-card:disabled {
  filter: grayscale(0.18);
}

.product-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  object-fit: cover;
}

.product-card .body {
  padding: 12px;
}

.product-card h3 {
  margin: 0 0 3px;
  font-size: 15px;
}

.product-card p,
.small {
  color: var(--muted);
  font-size: 11px;
}

.product-card strong {
  font-size: 16px;
}

.stock-badge {
  position: absolute;
  left: 10px;
  top: 10px;
  padding: 4px 7px;
  border-radius: 4px;
  background: #f5eee2;
  color: var(--danger);
  font-size: 11px;
  font-weight: 800;
}

.card-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.cart-panel {
  max-height: calc(100vh - 118px);
  display: flex;
  flex-direction: column;
}

.mobile-order-panel {
  display: none;
}

.cart-head,
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.cart-head h2,
.panel-head h2 {
  margin: 0;
  font-size: 17px;
  text-transform: uppercase;
}

.order-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.cart-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.cart-list {
  flex: 0 0 clamp(170px, 28vh, 280px);
  min-height: 170px;
  overflow: auto;
}

.cart-item {
  display: grid;
  grid-template-columns: 62px 1fr 22px;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.cart-item img {
  width: 62px;
  height: 70px;
  border-radius: 5px;
  object-fit: cover;
}

.cart-item h3 {
  margin: 0 0 2px;
  font-size: 14px;
}

.sale-date-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 108px;
  gap: 10px;
  padding: 0 18px 14px;
  border-bottom: 1px solid var(--line);
}

.sale-date-controls label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.sale-date-controls .field {
  width: 100%;
}

.cart-item select {
  width: 100%;
  margin: 8px 0 4px;
}

.variant-stock {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
}

.qty-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stepper {
  display: grid;
  grid-template-columns: 26px 30px 26px;
  height: 30px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.stepper button {
  border: 0;
  background: #fffdf9;
}

.stepper span {
  display: grid;
  place-items: center;
}

.remove {
  border: 0;
  background: transparent;
  color: var(--iroko);
  font-size: 20px;
}

.checkout {
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(52vh, 520px);
  overflow: auto;
  padding: 16px 18px 18px;
  border-top: 1px solid var(--line);
}

.checkout-split-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.checkout-split-row .field {
  width: 100%;
}

.line {
  display: flex;
  justify-content: space-between;
  margin: 8px 0;
  color: var(--muted);
}

.line strong {
  color: var(--text);
}

.line.discount strong {
  color: var(--danger);
}

.grand {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 12px;
  margin: 12px 0;
  border-top: 1px dashed var(--line);
}

.grand span {
  font-size: 18px;
}

.grand strong {
  color: var(--duqqa);
  font-size: 25px;
}

.payment-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 10px 0 12px;
}

.payment-grid button {
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-2);
  font-weight: 800;
}

.payment-grid button.active {
  background: var(--duqqa);
  color: white;
}

.console-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  min-height: 116px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 253, 249, 0.8);
}

.metric span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 10px;
  color: var(--duqqa);
  font-size: 26px;
}

.dashboard-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.insight-card {
  min-height: 74px;
  padding: 14px 16px;
}

.insight-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.insight-card strong {
  display: block;
  margin-top: 7px;
  color: var(--iroko);
  font-size: 20px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.wide-chart {
  grid-column: 1 / -1;
}

.chart-card {
  min-height: 230px;
}

.bar-list {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(160px, 2fr) 100px;
  gap: 12px;
  align-items: center;
}

.bar-copy {
  display: grid;
  gap: 2px;
}

.bar-copy strong {
  font-size: 13px;
}

.bar-copy span {
  color: var(--muted);
  font-size: 11px;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--paper-2);
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--duqqa), var(--grove));
}

.bar-value {
  justify-self: end;
  color: var(--duqqa);
}

.empty-state {
  padding: 18px;
  color: var(--muted);
}

.management-grid {
  display: grid;
  grid-template-columns: minmax(520px, 1.5fr) minmax(360px, 1fr);
  gap: 14px;
}

.stock-adjustment-grid {
  grid-template-columns: minmax(440px, 0.95fr) minmax(560px, 1.08fr);
}

.stock-adjustment-grid .panel,
.stock-adjustment-grid .admin-form,
.stock-adjustment-grid .form-row,
.stock-adjustment-grid .split-row {
  min-width: 0;
}

.stock-adjustment-grid .field,
.stock-adjustment-grid .select,
.stock-adjustment-grid input,
.stock-adjustment-grid select {
  box-sizing: border-box;
  max-width: 100%;
  width: 100%;
}


.receive-lots-table {
  width: 100%;
  min-width: 0;
  height: 100%;
  table-layout: fixed;
}

.receive-lots-table .field,
.receive-lots-table .select,
.receive-lots-table input,
.receive-lots-table select {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.receive-lot-main {
  width: 27%;
}

.receive-lot-location {
  width: 11%;
}

.receive-lot-qty {
  width: 6.5%;
}

.receive-lot-cost {
  width: 6.5%;
}

.receive-lot-date {
  width: 12%;
}

.receive-lot-date .field {
  min-height: 32px;
  padding-left: 6px;
  padding-right: 2px;
  font-size: 12px;
}

.receive-lot-date .field::-webkit-calendar-picker-indicator {
  width: 15px;
  height: 15px;
  margin-left: 1px;
  padding: 0;
}

.receive-lot-action-cell {
  width: 8%;
}

.receive-lot-note {
  width: 29%;
}

.receive-lot-note .field {
  min-width: 0;
}

.lot-date-stack {
  display: grid;
  gap: 5px;
}

.receive-lot-actions {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.console-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.console-title h2 {
  margin: 2px 0 0;
  font-size: 21px;
}

.console-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.console-tabs button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 249, 0.74);
  color: var(--iroko);
  text-transform: capitalize;
}

.console-tabs button.active {
  border-color: var(--duqqa);
  background: var(--duqqa);
  color: white;
}

.date-filter {
  display: grid;
  grid-template-columns: 150px 150px 88px;
  gap: 8px;
  align-items: end;
}

.date-filter .field {
  width: 100%;
}

.console-panel {
  margin-top: 14px;
}

.table-scroll {
  max-height: calc(100vh - 224px);
  overflow: auto;
}

.daily-close-report .daily-close-meta,
.daily-close-report .compact-metrics,
.daily-close-report .dashboard-grid {
  padding: 16px 18px;
  margin: 0;
}

.daily-close-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.daily-close-meta span {
  color: var(--muted);
  font-size: 12px;
}

.daily-close-report .table-scroll {
  max-height: none;
  border-top: 1px solid var(--line);
}

.audit-detail {
  display: block;
  max-width: 440px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.table th {
  background: var(--paper-2);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.editable-table td {
  vertical-align: middle;
}

.editable-table .field,
.editable-table .select,
.mini-field {
  width: 100%;
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fffdf9;
  color: var(--text);
}

.mini-field {
  max-width: 112px;
}

.cost-preview-field,
.cost-preview-field:read-only {
  background: var(--paper-2);
  color: var(--muted);
  cursor: default;
}

.cost-override-field {
  border-color: rgba(88, 31, 18, 0.34);
  box-shadow: inset 3px 0 0 rgba(88, 31, 18, 0.24);
}

.workflow-note {
  margin: 0;
  padding: 12px 18px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.products-grid,
.discounts-grid {
  align-items: start;
}

.product-editor-list {
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 218px);
  padding: 14px;
  overflow: auto;
}

.editor-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf9;
}

.editor-card-head {
  display: grid;
  grid-template-columns: 82px 1fr 88px;
  gap: 10px;
  align-items: center;
}

.editor-card-head > div {
  display: grid;
  gap: 8px;
}

.image-dropzone {
  position: relative;
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  overflow: hidden;
  border: 1px dashed rgba(145, 125, 94, 0.7);
  border-radius: 6px;
  background: var(--paper-2);
  color: var(--iroko);
  cursor: pointer;
}

.image-dropzone.wide {
  width: 100%;
  height: 160px;
}

.image-dropzone img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-dropzone span {
  position: absolute;
  inset: auto 6px 6px;
  padding: 4px 5px;
  border-radius: 4px;
  background: rgba(20, 15, 9, 0.72);
  color: white;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.image-dropzone input {
  display: none;
}

.image-dropzone.dragging {
  border-color: var(--duqqa);
  box-shadow: 0 0 0 3px rgba(79, 32, 21, 0.12);
}

.toggle-row {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.variant-editor {
  display: grid;
  gap: 8px;
  overflow-x: auto;
}

.variant-header {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(150px, 0.9fr) minmax(170px, 1fr) 96px 88px 88px 88px;
  gap: 8px;
  min-width: 880px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.variant-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(150px, 0.9fr) minmax(170px, 1fr) 96px 88px 88px 88px;
  gap: 8px;
  min-width: 880px;
  align-items: center;
}

.new-variant-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(150px, 0.9fr) minmax(170px, 1fr) 96px 88px 88px 88px;
  gap: 8px;
  min-width: 880px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.sku-field {
  text-transform: uppercase;
}

.editor-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.admin-form {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
}

.split-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.admin-copy {
  padding: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.settings-branches-panel {
  order: 10;
}

.settings-integrations-panel {
  order: 11;
}

.settings-users-panel {
  order: 12;
  grid-column: 1 / -1;
}

.settings-users-panel .editable-table {
  min-width: 1040px;
}

.settings-users-panel .editable-table th:nth-child(3),
.settings-users-panel .editable-table td:nth-child(3) {
  min-width: 120px;
}

.settings-users-panel .editable-table th:nth-child(4),
.settings-users-panel .editable-table td:nth-child(4),
.settings-users-panel .editable-table th:nth-child(5),
.settings-users-panel .editable-table td:nth-child(5) {
  min-width: 170px;
}

.settings-integrations-panel .field:read-only,
.settings-integrations-panel .check-row {
  background: var(--paper-2);
  color: var(--muted);
  cursor: default;
}

.setting-card {
  overflow: auto;
}

.users-setting-card {
  grid-column: 1 / -1;
}

.textarea {
  min-height: 78px;
  padding-top: 10px;
  resize: vertical;
}

.strong {
  font-weight: 800;
}

.new-row td {
  background: rgba(242, 238, 230, 0.48);
}

.users-table {
  min-width: 860px;
}

.inventory-head {
  gap: 12px;
}

.inventory-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inventory-tools .select {
  min-width: 240px;
}

.inventory-metrics {
  padding: 16px 18px 0;
  margin-bottom: 16px;
}

.inventory-table {
  min-width: 1180px;
}

.inventory-table .field[type="date"] {
  min-width: 132px;
}

.inventory-grid {
  grid-template-columns: minmax(320px, 0.58fr) minmax(840px, 1.62fr);
  align-items: stretch;
}

.inventory-grid > .panel:nth-child(2) {
  display: flex;
  min-height: 100%;
  flex-direction: column;
}

.inventory-grid > .panel:nth-child(2) .table-scroll {
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
  overflow-x: hidden;
}

.inventory-grid > .panel:first-child,
.inventory-grid > .panel:first-child .admin-form,
.inventory-grid > .panel:first-child .form-row,
.inventory-grid > .panel:first-child .split-row {
  min-width: 0;
}

.inventory-grid > .panel:first-child .split-row {
  grid-template-columns: minmax(0, 1fr);
}

.inventory-grid > .panel:first-child .field,
.inventory-grid > .panel:first-child .select,
.inventory-grid > .panel:first-child input,
.inventory-grid > .panel:first-child select {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.expiry-grid {
  display: grid;
  gap: 14px;
}


.staff-report-grid {
  grid-template-columns: minmax(0, 1fr);
}

.staff-report-grid .panel,
.staff-report-grid .table-scroll {
  min-width: 0;
}

.staff-report-grid .field,
.staff-report-grid .select {
  min-width: 0;
  width: 100%;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 6px;
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(39, 116, 83, 0.1);
  color: var(--ok);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.warn {
  background: rgba(145, 125, 94, 0.16);
  color: var(--iroko);
}

.status-pill.danger {
  background: rgba(154, 52, 40, 0.1);
  color: var(--danger);
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
}

.settings-actions .primary {
  min-width: 180px;
}

.low {
  color: var(--danger);
  font-weight: 800;
}

.compact-form-row {
  margin-bottom: 10px;
}

.compact-form-row label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.platform-fee {
  color: var(--muted);
  font-size: 12px;
}

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: 430px;
  transform: translateX(100%);
  transition: 180ms ease;
  z-index: 10;
  border-left: 1px solid var(--line);
  background: #fffdf9;
  box-shadow: -20px 0 60px rgba(20, 15, 9, 0.18);
}

.drawer.open {
  transform: translateX(0);
}

.drawer-inner {
  padding: 26px;
}

.drawer table {
  width: 100%;
  border-collapse: collapse;
}

.drawer td {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.receipt-logo {
  display: flex;
  justify-content: center;
  margin: 0 0 12px;
}

.receipt-logo img {
  display: block;
  width: 120px;
  max-width: 58%;
  height: auto;
}

.camera-scanner {
  position: fixed;
  inset: 0;
  z-index: 22;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 15, 9, 0.72);
}

.camera-scanner-inner {
  width: min(100%, 520px);
  overflow: hidden;
  border: 1px solid rgba(244, 238, 228, 0.22);
  border-radius: 8px;
  background: #fffdf9;
  box-shadow: 0 24px 80px rgba(20, 15, 9, 0.32);
}

.camera-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.camera-head h2 {
  margin: 0;
  font-size: 18px;
}

.camera-head span,
.camera-order {
  color: var(--muted);
  font-size: 12px;
}

.camera-frame {
  position: relative;
  aspect-ratio: 3 / 4;
  background: #140f09;
}

.camera-frame video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-line {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 50%;
  height: 2px;
  background: rgba(244, 238, 228, 0.92);
  box-shadow: 0 0 18px rgba(244, 238, 228, 0.7);
}

.camera-fallback {
  display: grid;
  min-height: 220px;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.camera-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border-top: 1px solid var(--line);
}

@media print {
  @page {
    size: 80mm 200mm;
    margin: 4mm;
  }

  html,
  body {
    width: 80mm;
    min-width: 0;
    margin: 0;
    padding: 0;
    background: #fff;
    color: #111;
  }

  .app-shell,
  .toast,
  .camera-scanner,
  .receipt-action {
    display: none !important;
  }

  #app {
    display: block !important;
  }

  .drawer,
  .drawer.open {
    position: static !important;
    inset: auto !important;
    display: block !important;
    width: 72mm !important;
    min-height: auto !important;
    transform: none !important;
    border: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  .drawer-inner {
    width: 72mm !important;
    padding: 0 !important;
    font-size: 11px;
    line-height: 1.35;
  }

  .drawer-inner h2 {
    margin: 0 0 6px;
    font-size: 16px;
    text-align: center;
  }

  .receipt-logo {
    margin: 0 0 4mm;
  }

  .receipt-logo img {
    width: 30mm;
    max-width: 46mm;
  }

  .drawer-inner p {
    margin: 0 0 8px;
  }

  .drawer table {
    width: 100%;
  }

  .drawer td {
    padding: 5px 0;
    border-bottom: 1px dashed #aaa;
  }
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  transform: translateY(16px);
  opacity: 0;
  min-width: 260px;
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--smoky);
  color: white;
  box-shadow: 0 16px 40px rgba(20, 15, 9, 0.2);
  transition: 160ms ease;
  pointer-events: none;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1280px) {
  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .console-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .login-screen {
    grid-template-columns: 360px minmax(0, 1fr);
  }

  .login-brand img {
    width: min(100%, 300px);
  }

  .topbar {
    grid-template-columns: minmax(260px, 1fr) minmax(180px, 220px);
  }

  .topbar > div:last-child {
    justify-self: end;
  }

  .pos-layout,
  .management-grid,
  .products-grid,
  .discounts-grid {
    grid-template-columns: 1fr;
  }

  .mobile-order-panel {
    display: block;
    order: -1;
  }

  .pos-layout > .panel:not(.cart-panel):not(.mobile-order-panel) {
    order: 1;
  }

  .pos-layout > .cart-panel {
    order: 2;
  }

  .cart-panel > .cart-head,
  .cart-panel > .sale-date-controls {
    display: none;
  }

  .cart-panel,
  .product-editor-list {
    max-height: none;
  }

  .cart-list {
    flex-basis: auto;
    max-height: 38vh;
  }

  .checkout {
    flex: 0 1 auto;
    max-height: none;
    overflow: visible;
  }

  .product-grid {
    max-height: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr) 92px;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
  }

  .brand {
    padding: 0;
    border-bottom: 0;
  }

  .brand img {
    width: 54px;
    height: 50px;
  }

  .side-nav {
    display: flex;
    gap: 8px;
    padding-top: 0;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .nav-group {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
  }

  .nav-group-label {
    display: none;
  }

  .side-nav button,
  .logout,
  .sidebar .install-button {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0 12px;
    text-align: center;
    white-space: nowrap;
  }

  .user-card {
    display: none;
  }

  .logout,
  .sidebar .install-button {
    margin-top: 0;
  }

  .workspace {
    padding: 18px;
  }

  
.console-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .date-filter {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 88px;
  }

  .table-scroll,
  .setting-card,
  .panel {
    overflow-x: auto;
  }
}

@media (max-width: 760px) {

  .staff-report-grid {
    gap: 10px;
  }

  .staff-report-grid .panel,
  .staff-report-grid .table-scroll {
    overflow-x: hidden;
  }

  .mobile-card-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 10px;
  }

  .mobile-card-table thead {
    display: none;
  }

  .mobile-card-table,
  .mobile-card-table tbody,
  .mobile-card-table tr,
  .mobile-card-table td {
    display: block;
    width: 100%;
  }

  .mobile-card-table tr {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgba(255, 253, 249, 0.84);
  }

  .mobile-card-table td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    padding: 7px 0;
    border-bottom: 0;
    overflow-wrap: anywhere;
  }

  .mobile-card-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
  }

  body {
    font-size: 13px;
  }

  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-brand {
    min-height: 280px;
    padding: 26px;
  }

  .login-brand img {
    width: min(74vw, 260px);
  }

  .login-brand p {
    letter-spacing: 0.22em;
  }

  .login-panel {
    max-width: none;
    padding: 28px;
  }

  .demo-logins,
  .toolbar,
  .split-row {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-columns: 1fr auto;
  }

  .brand {
    display: none;
  }

  .side-nav {
    grid-column: 1 / -1;
    order: 2;
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .logout {
    justify-self: end;
    min-width: 88px;
  }

  .sidebar .install-button {
    grid-column: 1;
    justify-self: start;
    min-width: 104px;
  }

  .workspace {
    padding: 14px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: stretch;
  }

  .topbar > div:last-child {
    justify-self: start;
  }

  .page-title h1 {
    font-size: 22px;
  }

  .page-title p {
    letter-spacing: 0.18em;
  }

  .category-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 10px;
  }

  .category-tabs button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .console-tabs {
    flex-wrap: wrap;
  }

  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
  }

  .product-card {
    min-height: 0;
  }

  .product-card img {
    aspect-ratio: 1 / 1;
    height: auto;
  }

  .product-card .body {
    padding: 7px;
  }

  .product-card h3 {
    min-height: 30px;
    margin-bottom: 3px;
    font-size: 11px;
    line-height: 1.35;
  }

  .product-card p {
    min-height: 14px;
    margin: 0 0 4px;
    font-size: 10px;
    line-height: 1.25;
  }

  .product-card strong {
    font-size: 12px;
  }

  .card-foot {
    margin-top: 4px;
  }

  .cart-item {
    grid-template-columns: 54px 1fr 22px;
    padding: 12px;
  }

  .cart-item img {
    width: 54px;
    height: 62px;
  }

  .payment-grid,
  .console-grid,
  .dashboard-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .bar-value {
    justify-self: start;
  }

  .daily-close-meta {
    display: grid;
    align-items: start;
  }

  .date-filter {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .date-filter button {
    grid-column: 1 / -1;
  }

  .metric {
    min-height: 96px;
  }

  .metric strong {
    font-size: 22px;
  }

  .editor-card-head {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .editor-card-head .toggle-row {
    grid-column: 1 / -1;
  }

  .variant-row,
  .new-variant-row {
    grid-template-columns: 1fr 1fr;
    min-width: 0;
  }

  .variant-header {
    display: none;
  }

  .editor-actions,
  .settings-actions {
    flex-direction: column;
  }

  .editor-actions button,
  .settings-actions .primary {
    width: 100%;
  }

  .drawer {
    width: min(100vw, 430px);
  }

  .camera-scanner {
    padding: 0;
    place-items: stretch;
  }

  .camera-scanner-inner {
    width: 100%;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }

  .camera-head {
    flex: 0 0 auto;
  }

  .camera-frame {
    flex: 1 1 auto;
    min-height: 360px;
    aspect-ratio: auto;
  }

  .camera-actions {
    flex: 0 0 auto;
  }

  .toast {
    right: 12px;
    left: 12px;
    bottom: 12px;
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .workspace {
    padding: 10px;
  }

  .panel-head,
  .cart-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .panel-actions {
    width: 100%;
  }

  .panel-head button,
  .cart-head button {
    width: 100%;
  }

  .sale-date-controls {
    grid-template-columns: 1fr;
  }

  .inventory-tools {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .inventory-tools .select {
    min-width: 0;
  }

  .payment-grid,
  .console-grid,
  .dashboard-summary-grid,
  .variant-row,
  .new-variant-row,
  .checkout-split-row {
    grid-template-columns: 1fr;
  }

  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    padding: 8px;
  }

  .camera-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .camera-actions button,
  .camera-actions .camera-order {
    width: 100%;
  }

  .product-card {
    min-height: 0;
  }

  .product-card img {
    aspect-ratio: 1 / 1;
    height: auto;
  }

  .grand strong {
    font-size: 22px;
  }

  .table th,
  .table td {
    padding: 10px;
  }

  .admin-form {
    padding: 14px;
  }

  .users-table {
    min-width: 760px;
  }
}


.all-branch-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.branch-comparison-grid .chart-card {
  min-height: 250px;
}


@media (max-width: 760px) {
  .all-branch-summary {
    grid-template-columns: 1fr;
  }
}

.accounting-dashboard {
  align-items: start;
}

.accounting-table-scroll {
  max-height: 520px;
  overflow: auto;
}

.accounting-table {
  min-width: 1480px;
}

.accounting-table td {
  vertical-align: top;
}

.accounting-table .field,
.accounting-table .select {
  min-width: 132px;
  margin-bottom: 6px;
}

.accounting-table .wide-field {
  min-width: 220px;
}

.accounting-master-grid {
  margin-top: 16px;
}

.compact-form {
  padding: 14px 18px 4px;
}

@media (max-width: 900px) {
  .accounting-dashboard,
  .accounting-master-grid {
    grid-template-columns: 1fr;
  }

  .accounting-table-scroll {
    max-height: none;
  }
}
.accounting-sync-note {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(81, 32, 23, 0.04);
}

.accounting-sync-note strong {
  color: var(--brown);
}

.accounting-sync-note span,
.accounting-sync-note a {
  font-size: 12px;
}

.accounting-sync-note a {
  color: var(--brown);
  font-weight: 700;
}
.purchasing-metrics {
  margin-bottom: 14px;
}

.purchasing-grid {
  align-items: start;
}

.compact-table-scroll {
  max-height: 340px;
}

.purchase-items-table {
  min-width: 720px;
}

.purchase-items-table .select {
  min-width: 240px;
}

.purchasing-table {
  min-width: 1280px;
}

.purchasing-table .field + .field {
  margin-top: 6px;
}

.po-items-list {
  display: grid;
  gap: 4px;
  min-width: 260px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.row-actions {
  display: grid;
  gap: 6px;
}
.production-metrics {
  margin-bottom: 14px;
}

.production-grid {
  align-items: start;
}

.production-estimate {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: rgba(81, 32, 23, 0.035);
}

.production-estimate span,
.production-estimate small {
  color: var(--muted);
  font-size: 12px;
}

.production-bom-table {
  min-width: 900px;
}

.production-bom-table .select {
  min-width: 260px;
}

.production-materials-table {
  min-width: 1320px;
}

.production-batches-table {
  min-width: 1200px;
}

.production-materials-table .mini-field,
.production-bom-table .mini-field {
  min-width: 96px;
}

.cost-cell {
  white-space: nowrap;
}

.muted-row {
  opacity: 0.55;
}

@media (max-width: 1180px) {
  .production-grid {
    grid-template-columns: 1fr;
  }
}
/* Product console editor: compact image and SKU actions. */
.drop-overlay {
  position: absolute;
  inset: auto 6px 6px;
  padding: 4px 5px;
  border-radius: 4px;
  background: rgba(20, 15, 9, 0.72);
  color: white;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
}

.drop-overlay input {
  display: none;
}

.product-admin-list {
  display: grid;
  gap: 12px;
}

.product-admin-card {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 249, 0.72);
}

.product-admin-media {
  position: relative;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  overflow: hidden;
  border: 1px dashed rgba(145, 125, 94, 0.7);
  border-radius: 6px;
  background: var(--paper-2);
  color: var(--iroko);
}

.product-admin-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-admin-media > input[type="hidden"] {
  display: none;
}

.product-admin-main {
  min-width: 0;
}

.product-variant-table th:last-child,
.product-variant-table td:last-child {
  width: 84px;
  text-align: right;
}

@media (max-width: 760px) {
  .product-admin-card {
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .product-admin-media {
    width: 68px;
    height: 68px;
  }

  .product-variant-table .field {
    min-width: 118px;
  }

  .product-variant-table .mini-field {
    min-width: 74px;
  }
}


