:root {
  color-scheme: light;
  --bg: #f4f5f0;
  --panel: #ffffff;
  --panel-soft: #f9faf6;
  --text: #17211a;
  --muted: #667064;
  --line: #dde2d8;
  --accent: #16745f;
  --accent-dark: #0d5647;
  --danger: #b42318;
  --warning: #b54708;
  --shadow: 0 18px 48px rgba(23, 33, 26, .08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.35 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card,
.panel,
.metric,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(420px, 100%);
  padding: 24px;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 22px;
}

.login-logo img {
  width: min(280px, 100%);
  max-height: 96px;
  object-fit: contain;
  display: block;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand-mark-image {
  background: #fff;
  border: 1px solid var(--line);
  overflow: hidden;
}

.brand-mark-image img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
}

.store-identity {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.store-identity img {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
}

.login-brand-title {
  display: inline-block;
  font-size: 1.18rem;
}

.store-logo-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8faf7;
}

.store-logo-preview img {
  max-width: 150px;
  max-height: 82px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 1.55rem;
  margin-bottom: 6px;
}

h2 {
  font-size: 1.15rem;
  margin-bottom: 14px;
}

.muted {
  color: var(--muted);
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.embedded-layout {
  display: block;
  min-height: 100vh;
}

.embedded-page {
  background: var(--surface);
}

.embedded-page .main {
  min-height: 100vh;
}

.embedded-page .content {
  padding: 12px;
}

.embedded-page .panel {
  box-shadow: none;
}

.sidebar {
  background: #17211a;
  color: #edf5ea;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px;
  position: sticky;
  top: 0;
  scrollbar-color: rgba(216, 227, 213, .4) transparent;
  scrollbar-width: thin;
}

.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(216, 227, 213, .28);
  border-radius: 999px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(216, 227, 213, .42);
}

.sidebar .brand {
  margin-bottom: 26px;
}

.support-label {
  display: inline-flex;
  margin-top: 4px;
  border-radius: 999px;
  background: #fff1f0;
  color: var(--danger);
  font-size: 11px;
  font-weight: 900;
  padding: 2px 8px;
}

.dashboard-shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.shortcut-card {
  display: grid;
  align-content: space-between;
  min-height: 132px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: #fff;
  padding: 18px;
  transition: transform .15s ease, box-shadow .15s ease;
}

.shortcut-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 60px rgba(23, 33, 26, .14);
}

.shortcut-card span {
  font-size: 1.2rem;
  font-weight: 900;
}

.shortcut-card strong {
  color: rgba(255, 255, 255, .84);
  font-size: .92rem;
  font-weight: 700;
}

.shortcut-green {
  background: #16745f;
}

.shortcut-blue {
  background: #1f5f9f;
}

.shortcut-teal {
  background: #0f766e;
}

.shortcut-dark {
  background: #17211a;
}

.shortcut-orange {
  background: #b45309;
}

.shortcut-purple {
  background: #6d4aff;
}

.shortcut-red {
  background: #b42318;
}

.shortcut-gray {
  background: #52605a;
}

.nav {
  display: grid;
  gap: 12px;
}

.nav-group {
  display: grid;
  gap: 6px;
}

.nav-title {
  align-items: center;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius);
  color: #e8f3e6;
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  justify-content: space-between;
  padding: 9px 11px;
  text-align: left;
  width: 100%;
}

.nav-title:hover {
  background: rgba(32, 132, 104, .22);
  border-color: rgba(78, 174, 141, .34);
}

.nav-sub {
  border-left: 1px solid rgba(255, 255, 255, .14);
  display: none;
  gap: 4px;
  margin-left: 14px;
  padding-left: 8px;
}

.nav a {
  border-radius: var(--radius);
  color: #d8e3d5;
  font-size: 14px;
  padding: 9px 12px;
}

.nav-inline-form {
  margin: 0;
}

.nav-inline-form button {
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: rgba(180, 35, 24, .18);
  color: #ffd7d3;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  padding: 9px 12px;
  text-align: left;
}

.nav-inline-form button:hover {
  background: rgba(180, 35, 24, .28);
  color: #fff;
}

.nav-group.open .nav-title {
  background: rgba(32, 132, 104, .28);
  border-color: rgba(78, 174, 141, .4);
  color: #fff;
}

.nav-group.open .nav-sub {
  display: grid;
}

.nav-chevron {
  color: #b8c8b8;
  font-size: 12px;
  transition: transform .16s ease;
}

.nav-group.open .nav-chevron {
  transform: rotate(180deg);
}

.nav a.active,
.nav a:hover {
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.content {
  padding: 18px 24px 24px;
}

.grid {
  display: grid;
  gap: 16px;
}

.metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  padding: 16px;
}

.metric strong {
  display: block;
  font-size: 1.55rem;
}

.panel {
  padding: 16px;
}

.page-actions,
.table-actions,
.sticky-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.page-actions {
  margin-bottom: 16px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 4;
  background: linear-gradient(to top, var(--panel) 72%, rgba(255, 255, 255, 0));
  border-top: 1px solid var(--line);
  margin: 16px -18px -18px;
  padding: 12px 18px;
}

.form-card,
.form-section,
.filter-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.form-section {
  display: grid;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.search-field {
  display: grid;
  gap: 6px;
}

.inline-help {
  color: var(--muted);
  font-size: .84rem;
  font-weight: 700;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.danger-zone {
  background: #fff7f6;
  border: 1px solid #f1b8b3;
  border-radius: var(--radius);
  padding: 16px;
}

.split {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 18px;
  align-items: start;
}

.form-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  grid-column: 1 / -1;
}

.form-title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

body.has-panel-maximized {
  overflow: hidden;
}

.panel-maximized {
  position: fixed;
  inset: 12px;
  z-index: 80;
  overflow: auto;
  max-height: calc(100vh - 24px);
  box-shadow: 0 24px 80px rgba(23, 33, 26, .24);
}

.panel-maximized.form-grid {
  align-content: start;
}

.product-form.panel-maximized,
.product-form:fullscreen {
  background: var(--panel);
  border-radius: 0;
  gap: 9px;
  max-height: 100vh;
  padding: 12px;
}

.product-form:fullscreen {
  overflow: auto;
}

.product-form.panel-maximized .field,
.product-form:fullscreen .field {
  gap: 3px;
}

.product-form.panel-maximized input,
.product-form.panel-maximized select,
.product-form.panel-maximized textarea,
.product-form:fullscreen input,
.product-form:fullscreen select,
.product-form:fullscreen textarea {
  min-height: 32px;
  padding: 5px 9px;
}

.product-form.panel-maximized textarea,
.product-form:fullscreen textarea {
  min-height: 70px;
}

.product-form.panel-maximized .product-suppliers-box,
.product-form:fullscreen .product-suppliers-box {
  gap: 8px;
  padding: 10px;
}

.product-form.panel-maximized > .actions,
.product-form:fullscreen > .actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: linear-gradient(to top, var(--panel) 82%, rgba(255, 255, 255, 0));
  border-top: 1px solid var(--line);
  margin: 4px -12px -12px;
  padding: 10px 12px;
}

.pos-shell {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(340px, 430px);
  gap: 10px;
  align-items: start;
}

.sale-workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: start;
}

.component-title {
  font-size: 1.25rem;
  margin: 0 0 2px;
}

.sale-panel-title {
  font-size: .95rem;
  line-height: 1.1;
  margin: 0 0 6px;
}

.sale-header-card,
.sale-item-card,
.sale-items-card,
.sale-close-card {
  box-shadow: 0 20px 60px rgba(23, 33, 26, .09);
}

.sale-header-card,
.sale-items-card,
.sale-close-card,
.pos-entry,
.pos-cart {
  padding: 10px 12px;
}

.sale-header-card,
.sale-item-card,
.sale-items-card {
  grid-column: 1;
}

.sale-close-card {
  grid-column: 1;
}

.sale-header-card {
  order: 1;
}

.sale-items-card {
  order: 2;
  display: grid;
  gap: 10px;
}

.sale-item-card {
  order: 3;
}

.sale-close-card {
  order: 4;
}

.sale-customer-row {
  display: grid;
  grid-template-columns: minmax(140px, .32fr) minmax(360px, 1fr) minmax(150px, .35fr) minmax(150px, auto);
  gap: 10px;
  align-items: end;
}

.sale-transaction-row {
  display: grid;
  grid-template-columns: minmax(170px, 230px) minmax(130px, 165px) minmax(130px, 155px) minmax(190px, 1fr) minmax(130px, 155px);
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.sale-transaction-code input {
  font-weight: 900;
  text-align: right;
}

.sale-cancel-button {
  min-height: 36px;
  padding-inline: 12px;
}

.sale-status-field {
  justify-items: end;
  justify-self: end;
  min-width: 130px;
}

.sale-status-field .status-badge {
  justify-content: center;
  min-height: 36px;
  width: 100%;
}

.sale-meta-row {
  display: grid;
  grid-template-columns: minmax(180px, .6fr) minmax(160px, .45fr) minmax(260px, 1fr);
  gap: 10px;
  align-items: end;
  margin-top: 6px;
}

.sale-customer-code input {
  text-align: right;
  font-weight: 900;
}

.subtle-sale-warning {
  margin: 6px 0 0;
  font-size: .88rem;
}

.settings-customer-row {
  display: grid;
  grid-template-columns: minmax(110px, 160px) auto minmax(260px, 1fr);
  gap: 8px;
  align-items: end;
}

.sale-scan-row {
  display: grid;
  grid-template-columns: minmax(300px, .95fr) minmax(420px, 1.55fr);
  gap: 12px;
  align-items: end;
}

.sale-scan-row-bottom {
  grid-template-columns: minmax(210px, 330px) 96px 96px 110px 130px minmax(150px, 190px);
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 8px;
}

.sale-inline-total {
  align-self: end;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  display: grid;
  gap: 2px;
  min-height: 30px;
  padding: 4px 9px;
}

.sale-inline-total span {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  line-height: 1;
}

.sale-inline-total strong {
  color: var(--text);
  font-size: .96rem;
  line-height: 1.05;
}

.sale-inline-total-main {
  background: #17211a;
  border-color: #17211a;
  color: #fff;
}

.sale-inline-total-main span {
  color: #cbd8c7;
}

.sale-inline-total-main strong {
  color: #fff;
  font-size: 1.12rem;
}

.visually-hidden {
  border: 0 !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  height: 1px !important;
  margin: -1px !important;
  overflow: hidden !important;
  padding: 0 !important;
  position: absolute !important;
  white-space: nowrap !important;
  width: 1px !important;
}

.sale-item-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 90px 130px;
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}

.sale-item-adjust-row {
  grid-template-columns: 150px 150px minmax(220px, 1fr);
}

.sale-items-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(221, 226, 216, .35);
  height: clamp(150px, 24vh, 360px);
  max-height: 42vh;
  overflow: auto;
  padding-bottom: 3px;
  scrollbar-color: var(--accent) #e8ece4;
  scrollbar-width: thin;
}

.sale-items-wrap::-webkit-scrollbar {
  height: 14px;
  width: 14px;
}

.sale-items-wrap::-webkit-scrollbar-track {
  background: #e8ece4;
  border-radius: 999px;
}

.sale-items-wrap::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 999px;
}

.sale-items-table {
  min-width: 920px;
}

.sale-items-table thead th {
  background: var(--accent);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 2;
}

.sale-items-table th,
.sale-items-table td {
  padding: 3px 7px;
  vertical-align: middle;
}

.sale-items-table tbody td {
  line-height: 1.08;
}

.sale-items-table th:nth-child(1) { width: 110px; }
.sale-items-table th:nth-child(3),
.sale-items-table th:nth-child(4) { width: 80px; }
.sale-items-table th:nth-child(5) { width: 76px; }
.sale-items-table th:nth-child(6),
.sale-items-table th:nth-child(7) { width: 120px; }
.sale-items-table th:nth-child(8) { width: 105px; }

.line-qty-input {
  min-height: 24px;
  padding: 2px 6px;
  text-align: center;
}

.sale-list-total {
  background: #17211a;
  border-radius: var(--radius);
  color: #fff;
  min-width: 180px;
  padding: 10px 12px;
  text-align: right;
}

.sale-list-total span {
  color: #cbd8c7;
  display: block;
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.sale-list-total strong {
  display: block;
  font-size: 1.25rem;
}

.sale-close-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 160px)) minmax(260px, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.sale-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  margin-bottom: 8px;
  padding: 8px 10px;
}

.sale-summary span {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-weight: 800;
}

.sale-summary strong {
  color: var(--text);
}

.sale-summary-total {
  border-left: 1px solid var(--line);
  border-top: 0;
  color: var(--text) !important;
  font-size: 1.05rem;
  padding-left: 12px;
}

.sale-final-summary {
  grid-template-columns: minmax(160px, 1fr) minmax(220px, auto);
}

.sale-final-summary .sale-summary-total {
  font-size: 1.12rem;
  justify-items: end;
  padding-left: 18px;
  text-align: right;
}

.sale-final-summary .sale-summary-total strong {
  font-size: 1.32rem;
}

.sale-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  margin-top: 8px;
}

.sale-footer-left,
.sale-footer-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sale-footer-right {
  justify-content: flex-end;
}

.sale-footer-actions .btn {
  min-width: 130px;
  width: auto;
}

.sale-footer-left .sale-cancel-button {
  min-width: 0;
}

.sale-finalize-button {
  min-width: 190px !important;
  padding-inline: 18px;
}

.sale-workspace textarea,
.pos-shell textarea {
  min-height: 48px;
}

.pos-entry,
.pos-cart {
  box-shadow: 0 20px 60px rgba(23, 33, 26, .1);
}

.pos-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.sale-header-card > .pos-heading {
  justify-content: flex-end;
  margin-bottom: 10px;
}

.pos-total {
  flex: 0 0 170px;
  border-radius: var(--radius);
  background: #17211a;
  color: #fff;
  padding: 12px 14px;
  text-align: right;
}

.pos-total span {
  display: block;
  color: #cbd8c7;
  font-size: .82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.pos-total strong {
  display: block;
  font-size: 1.55rem;
}

.pos-grid {
  display: grid;
  grid-template-columns: minmax(130px, .72fr) minmax(260px, 1.28fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.pos-grid + .product-preview + .pos-grid {
  grid-template-columns: minmax(230px, 1fr) 90px 130px;
}

.pos-money-grid {
  grid-template-columns: 130px 130px;
  justify-content: end;
}

.pos-grid .field {
  margin: 0;
}

.small-field input {
  text-align: right;
}

.product-preview {
  display: grid;
  gap: 3px;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  margin: 6px 0 10px;
  padding: 9px 11px;
}

.product-preview span {
  color: var(--muted);
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-weight: 700;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.login-remember {
  justify-content: flex-start;
  margin-top: -4px;
  font-size: .93rem;
}

.login-help-link {
  color: var(--accent-dark);
  font-size: .93rem;
  font-weight: 800;
  justify-self: center;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.mini-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
  margin-top: 6px;
}

.mini-check input {
  width: 16px;
  min-height: 16px;
}

.cart-list {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  max-height: 390px;
  overflow: auto;
}

.empty-cart {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 12px;
}

.cart-item span,
.cart-item small {
  display: block;
  color: var(--muted);
}

.cart-item > div:last-child {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.checkout-grid {
  display: grid;
  grid-template-columns: minmax(140px, .75fr) minmax(170px, .75fr) minmax(110px, .45fr);
  gap: 10px;
  align-items: end;
}

[data-card-fee-field] {
  max-width: 260px;
}

.payment-shell {
  grid-template-columns: minmax(620px, 1fr) minmax(300px, 380px);
}

.payment-shell .pos-entry {
  display: grid;
  gap: 12px;
}

.payment-shell .pos-heading {
  margin-bottom: 6px;
}

.payment-method-field {
  margin: 0;
}

.payment-shell .checkout-grid {
  grid-template-columns: minmax(145px, .7fr) minmax(145px, .7fr) minmax(95px, .35fr) minmax(120px, .42fr);
  gap: 10px;
  align-items: end;
}

.payment-card-fee-field {
  max-width: none;
}

.payment-card-fee-field[hidden] {
  display: none;
}

.payment-card-operator-field {
  align-self: end;
}

.payment-card-operator-field .compact-check {
  min-height: 36px;
  padding: 0 10px;
  justify-content: flex-start;
  gap: 8px;
}

.payment-card-operator-field .compact-check input {
  width: 18px;
  height: 18px;
}

.payment-card-operator-field[hidden],
.payment-installments-count-field[hidden],
.installments-frame[hidden] {
  display: none;
}

.payment-shell .installments-frame {
  margin-top: 2px;
}

.purchase-entry {
  grid-column: 1 / -1;
}

.purchase-header-grid {
  display: grid;
  grid-template-columns: 140px minmax(280px, 1.2fr) 170px 170px minmax(220px, .8fr);
  gap: 8px;
  align-items: end;
}

.purchase-cart-panel {
  grid-column: 1 / -1;
}

.purchase-scan-row {
  display: grid;
  grid-template-columns: minmax(180px, .55fr) minmax(320px, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.purchase-scan-row-bottom {
  margin-top: -2px;
}

.purchase-scan-row .btn {
  white-space: nowrap;
}

.compact-preview {
  min-height: 38px;
  margin: 0 0 8px;
  padding: 7px 10px;
}

.purchase-items-wrap {
  min-height: 240px;
  max-height: 38vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.purchase-items-wrap .cart-list {
  max-height: none;
  margin-bottom: 0;
}

.installments-frame {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.installments-frame table {
  margin: 0;
  min-width: 0;
  width: 100%;
}

.installments-frame th:nth-child(1),
.installments-frame td:nth-child(1) {
  width: 100px;
}

.installments-frame th:nth-child(2),
.installments-frame td:nth-child(2) {
  width: 150px;
}

.installment-date-input {
  max-width: 135px;
}

.purchase-totals-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.table-input {
  min-height: 28px;
  padding: 3px 7px;
  text-align: right;
}

.save-customer {
  min-height: 30px;
}

.checkout-btn {
  width: 100%;
  min-height: 44px;
  font-size: 1rem;
}

.search-modal {
  width: min(760px, calc(100% - 28px));
  max-height: min(720px, calc(100vh - 40px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.wide-modal {
  width: min(1060px, calc(100% - 28px));
}

.finance-page-actions {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.finance-payment-modal {
  width: min(820px, calc(100% - 28px));
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.pagination .active {
  background: var(--brand);
  color: white;
}

.modal-table {
  max-height: 58vh;
  overflow: auto;
}

[data-browser-row] {
  cursor: pointer;
}

[data-browser-row]:hover {
  background: var(--panel-soft);
}

.search-modal::backdrop {
  background: rgba(23, 33, 26, .48);
}

.confirm-modal {
  width: min(420px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
}

.confirm-modal::backdrop,
.system-notice-modal::backdrop {
  background: rgba(23, 33, 26, .52);
}

.system-notice-modal {
  width: min(560px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
}

.confirm-box {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.confirm-box h2 {
  margin-bottom: 0;
}

.confirm-box p {
  color: var(--muted);
  margin-bottom: 0;
  white-space: pre-line;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-search {
  margin-bottom: 12px;
}

.modal-filter-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  margin-bottom: 12px;
}

.modal-filter-grid .modal-search {
  margin-bottom: 0;
}

.modal-list {
  display: grid;
  gap: 8px;
  max-height: 480px;
  overflow: auto;
}

.modal-row {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
  padding: 11px 12px;
  text-align: left;
}

.modal-row:hover,
.modal-row:focus {
  border-color: var(--accent);
  outline: none;
}

.modal-row span {
  color: var(--muted);
}

.sale-product-choice {
  align-items: center;
  grid-template-columns: minmax(0, 1fr) auto;
}

.sale-product-choice input[type="checkbox"] {
  height: 22px;
  width: 22px;
}

.sale-product-choice.is-selected {
  background: #e8f3ef;
  border-color: var(--accent);
}

.modal-actions {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 12px;
}

.report-grid {
  grid-template-columns: minmax(280px, 420px) 1fr;
  margin-top: 18px;
}

.report-section {
  margin-top: 18px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.stock-filter-form {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.stock-filter-row {
  display: grid;
  gap: 12px;
  align-items: end;
}

.stock-filter-row.product-row {
  grid-template-columns: minmax(210px, .72fr) minmax(300px, 1.25fr) minmax(130px, .42fr) minmax(210px, .72fr);
}

.stock-filter-row.supplier-row {
  grid-template-columns: minmax(230px, .8fr) minmax(360px, 1.35fr) minmax(240px, .95fr);
}

.stock-filter-row.detail-row {
  grid-template-columns: minmax(95px, .28fr) minmax(130px, .36fr) minmax(520px, 1.7fr) minmax(190px, auto);
}

.stock-filter-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
}

.stock-filter-actions .btn {
  width: 220px;
  min-width: 120px;
}

.stock-filter-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.stock-filter-options .check-row {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  flex: 0 0 auto;
  min-height: 36px;
  padding: 7px 10px;
  white-space: nowrap;
}

.product-movement-filter {
  display: grid;
  gap: 10px;
}

.product-movement-row {
  display: grid;
  gap: 10px;
  align-items: end;
}

.product-movement-row.product-row {
  grid-template-columns: minmax(180px, 260px) minmax(300px, 1fr) minmax(130px, .42fr) minmax(210px, .58fr);
}

.product-movement-row.person-row {
  grid-template-columns: minmax(180px, 280px) minmax(320px, 1fr) minmax(150px, .42fr) minmax(150px, .42fr) minmax(140px, auto);
}

.movement-code-field .inline-search {
  grid-template-columns: minmax(90px, 1fr) auto;
}

.movement-table-wrap {
  max-height: 62vh;
  overflow: auto;
}

.movement-table {
  min-width: 980px;
  table-layout: fixed;
}

.movement-table th,
.movement-table td {
  overflow: hidden;
  padding: 5px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.movement-table th:nth-child(1) { width: 92px; }
.movement-table th:nth-child(2) { width: 92px; }
.movement-table th:nth-child(3) { width: 92px; }
.movement-table th:nth-child(4) { width: 320px; }
.movement-table th:nth-child(5) { width: 120px; }
.movement-table th:nth-child(6),
.movement-table th:nth-child(7),
.movement-table th:nth-child(8) { width: 72px; }
.movement-table th:nth-child(9) { width: 86px; }

.table-mini-btn {
  min-height: 26px;
  min-width: 0;
  padding: 3px 8px;
}

.balance-filter-form {
  display: grid;
  gap: 10px;
}

.balance-filter-row {
  display: grid;
  gap: 10px;
  align-items: end;
}

.balance-filter-row-main {
  grid-template-columns: minmax(130px, 160px) minmax(130px, 160px) minmax(180px, 210px) minmax(420px, 1fr);
}

.balance-filter-row-secondary {
  grid-template-columns: minmax(420px, 1fr) minmax(190px, 220px) minmax(150px, 180px) minmax(190px, 220px) minmax(150px, 180px);
}

.balance-code-field input {
  text-align: center;
}

.balance-product-search-btn,
.balance-reference-search-btn,
.balance-supplier-search-btn,
.balance-submit-btn {
  align-self: end;
  min-height: 30px;
  width: 100%;
}

.balance-product-name input,
.balance-references-field input,
.balance-supplier-code-field input {
  min-width: 0;
}

.balance-supplier-code-field {
  max-width: none;
}

.balance-filter-options {
  grid-template-columns: repeat(2, minmax(180px, 240px));
  width: fit-content;
}

.balance-filter-options .check-row {
  overflow: hidden;
}

.balance-frame {
  margin-top: 4px;
}

.balance-table-wrap {
  max-height: 62vh;
  overflow: auto;
}

.balance-table {
  min-width: 900px;
  table-layout: fixed;
}

.balance-table th,
.balance-table td {
  overflow: hidden;
  padding: 5px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-table th:nth-child(1) { width: 100px; }
.balance-table th:nth-child(2) { width: 360px; }
.balance-table th:nth-child(3) { width: 110px; }
.balance-table th:nth-child(4) { width: 130px; }
.balance-table th:nth-child(5) { width: 260px; }

.stock-report-frame {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding: 12px;
}

.stock-report-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.stock-report-head h2 {
  font-size: 1rem;
  margin: 0;
}

.stock-report-head .report-actions {
  margin-top: 0;
}

.stock-report-frame:fullscreen {
  background: var(--bg);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  height: 100vh;
  padding: 18px;
}

.stock-report-frame:fullscreen .stock-table-wrap {
  max-height: calc(100vh - 96px);
}

.stock-table-wrap {
  max-height: clamp(420px, 62vh, 760px);
  overflow: auto;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-color: var(--accent) #e8ece4;
  scrollbar-width: thin;
}

.stock-table-wrap::-webkit-scrollbar {
  height: 14px;
  width: 14px;
}

.stock-table-wrap::-webkit-scrollbar-track {
  background: #e8ece4;
  border-radius: 999px;
}

.stock-table-wrap::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 999px;
}

.stock-table {
  min-width: 1240px;
  table-layout: fixed;
}

.stock-table thead th {
  background: var(--accent);
  color: #fff;
  font-size: .78rem;
  position: sticky;
  top: 0;
  z-index: 2;
}

.stock-table .stock-available-head {
  background: #0f6f5c;
}

.stock-table .stock-quantity-cell,
.stock-table .stock-consigned-cell,
.stock-table .stock-total-cell {
  font-weight: 800;
  text-align: center;
}

.stock-table .stock-quantity-cell {
  background: #f1fbf6;
}

.stock-quantity-pill {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: .9rem;
  justify-content: center;
  min-width: 44px;
  padding: 4px 10px;
}

.stock-quantity-pill.success {
  background: #dff5ea;
  color: #0b6b48;
}

.stock-quantity-pill.neutral {
  background: #eef2ec;
  color: #647064;
}

.stock-quantity-pill.danger {
  background: #fee5e5;
  color: #b42318;
}

.stock-table .stock-consigned-cell {
  color: #8a5a00;
}

.stock-table .stock-total-cell {
  color: var(--ink);
}

[data-sortable-ready] thead th {
  cursor: pointer;
  padding-right: 22px;
  position: sticky;
  user-select: none;
}

[data-sortable-ready] thead th::after {
  content: "↕";
  font-size: .85rem;
  opacity: .68;
  position: absolute;
  right: 8px;
}

[data-sortable-ready] thead th[data-sort-direction="asc"]::after {
  content: "↑";
  opacity: 1;
}

[data-sortable-ready] thead th[data-sort-direction="desc"]::after {
  content: "↓";
  opacity: 1;
}

.stock-table thead th:first-child {
  border-top-left-radius: var(--radius);
}

.stock-table thead th:last-child {
  border-top-right-radius: var(--radius);
}

.stock-table th:nth-child(1) { width: 88px; }
.stock-table th:nth-child(2) { width: 230px; }
.stock-table th:nth-child(3) { width: 78px; }
.stock-table th:nth-child(4) { width: 96px; }
.stock-table th:nth-child(5),
.stock-table th:nth-child(6) { width: 86px; }
.stock-table th:nth-child(7),
.stock-table th:nth-child(8),
.stock-table th:nth-child(9),
.stock-table th:nth-child(10) { width: 122px; }
.stock-table th:nth-child(11) { width: 145px; }

.stock-table th,
.stock-table td {
  padding: 7px 10px;
}

.stock-table tbody td {
  line-height: 1.22;
}

.stock-product-cell {
  font-weight: 800;
}

.inline-details {
  margin-top: 10px;
}

.inline-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 800;
  margin-bottom: 10px;
}

.inline-metric {
  box-shadow: none;
  margin-top: 10px;
}

.receipt {
  max-width: 820px;
  margin: 0 auto;
}

.receipt-coupon {
  max-width: 380px;
}

.receipt-paper {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.receipt-coupon .receipt-paper {
  font-size: .88rem;
  padding: 16px;
}

.receipt-coupon .receipt-head h2 {
  font-size: 1rem;
  margin-bottom: 4px;
}

.receipt-coupon th,
.receipt-coupon td {
  padding: 6px 4px;
}

.receipt-head {
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: center;
  gap: 14px;
  border-bottom: 1px dashed #9aa395;
  padding-bottom: 14px;
  text-align: left;
}

.receipt-head-no-logo {
  grid-template-columns: 1fr;
  text-align: center;
}

.receipt-logo-box {
  width: 112px;
  min-height: 82px;
  display: grid;
  place-items: center;
  border: 1px solid #e0e6dc;
  border-radius: 8px;
  background: #fff;
}

.receipt-logo {
  max-width: 96px;
  max-height: 70px;
  object-fit: contain;
  display: block;
}

.receipt-store-info {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.receipt-store-info h2 {
  margin: 0 0 4px;
}

.receipt-meta {
  display: grid;
  gap: 5px;
  margin: 14px 0;
}

.receipt-table {
  min-width: 0;
}

.receipt-total {
  display: flex;
  justify-content: space-between;
  border-top: 1px dashed #9aa395;
  font-size: 1.2rem;
  font-weight: 900;
  margin-top: 14px;
  padding-top: 12px;
}

.receipt-payment {
  border-top: 1px dashed #9aa395;
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding-top: 10px;
}

.receipt-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.report-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.code-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 12px;
}

.product-code-fields {
  grid-template-columns: minmax(112px, .55fr) minmax(180px, 1fr) minmax(190px, 1fr) minmax(124px, .7fr);
}

.product-code-fields .field:first-child input {
  text-align: right;
  font-weight: 900;
}

.product-status-field.is-inactive label {
  color: var(--danger);
}

.notice-all-check {
  align-self: end;
  min-height: 36px;
}

.notice-store-picker {
  display: grid;
  gap: 8px;
}

.notice-store-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.password-toggle {
  margin-top: 6px;
  min-height: auto;
  padding: 0;
}

.password-toggle span {
  font-size: .9rem;
}

.product-barcode-actions {
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 0;
}

.barcode-modal {
  width: min(620px, calc(100% - 28px));
}

.barcode-print-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 12px;
  margin: 10px 0 14px;
}

.barcode-display-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 8px 12px;
  margin-bottom: 14px;
}

.barcode-print-area {
  display: grid;
  place-items: center;
  padding: 14px;
}

.barcode-label {
  display: grid;
  justify-items: center;
  gap: var(--label-gap, 4px);
  width: var(--label-width, 82mm);
  min-height: var(--label-height, 38mm);
  border: 1px dashed var(--line);
  border-radius: 4px;
  background: #fff;
  color: #111;
  font-size: var(--label-font-size, 12px);
  padding: 8px 10px;
  text-align: center;
}

.barcode-label > strong:first-child {
  max-width: 100%;
  overflow: hidden;
  font-size: .92rem;
  line-height: 1.1;
  justify-self: stretch;
  text-align: var(--label-description-align, center);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.barcode-label span {
  color: #333;
  font-size: .78rem;
  min-height: 1em;
  justify-self: stretch;
}

.barcode-info-line {
  display: grid;
  gap: var(--label-gap, 4px);
  justify-self: stretch;
  width: 100%;
}

.barcode-label.label-info-inline .barcode-info-line {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
}

.barcode-label [data-barcode-product-reference] {
  text-align: var(--label-reference-align, center);
}

.barcode-label [data-barcode-product-price] {
  font-weight: 800;
  text-align: var(--label-price-align, center);
}

.barcode-label.label-info-inline [data-barcode-product-reference] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.barcode-label.label-info-inline [data-barcode-product-price] {
  text-align: right;
  white-space: nowrap;
}

.barcode-svg-wrap {
  width: 100%;
}

.barcode-svg {
  display: block;
  width: 100%;
  height: var(--label-bars-height, 22mm);
}

.barcode-number {
  font-size: .88rem;
  letter-spacing: 2px;
}

.barcode-print-sheet {
  display: none;
}

.barcode-editor {
  display: grid;
  gap: 12px;
}

.barcode-editor[hidden] {
  display: none;
}

.barcode-editor .editor-preview {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.barcode-editor-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

@page barcodePortrait {
  size: A4 portrait;
  margin: 0;
}

@page barcodeLandscape {
  size: A4 landscape;
  margin: 0;
}

.reference-grid-panel {
  display: block;
}

.reference-grid-header {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: 12px;
  align-items: end;
}

.inline-lookup {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.reference-grid-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.15fr) minmax(220px, 1.15fr) minmax(110px, .5fr) minmax(110px, .5fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}

.reference-grid-controls .money-field input {
  text-align: right;
}

.reference-grid-supplier-row {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(260px, 1fr);
  gap: 12px;
  align-items: end;
  margin-top: 10px;
}

.reference-grid-supplier-row input[readonly] {
  background: #f8faf7;
}

.reference-grid-lock-notice {
  background: #f4faf6;
  border: 1px solid #d7e8df;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  margin: 10px 0 0;
  padding: 8px 10px;
}

.reference-grid-wrap {
  border: 1px solid #d7e8df;
  border-radius: 8px;
  margin-top: 16px;
  max-height: 430px;
  overflow: auto;
  background: #fff;
}

.reference-grid-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: max(720px, calc(126px + (var(--grid-size-count, 4) * 150px)));
  table-layout: fixed;
  width: max(100%, calc(126px + (var(--grid-size-count, 4) * 150px)));
}

.reference-grid-color-col {
  width: 126px;
}

.reference-grid-size-col {
  width: 150px;
}

.reference-grid-table th,
.reference-grid-table td {
  border-bottom: 1px solid #dcece4;
  border-right: 1px solid #dcece4;
  padding: 8px;
  text-align: center;
  white-space: nowrap;
}

.reference-grid-table th:first-child,
.reference-grid-table td:first-child {
  border-left: 1px solid #dcece4;
}

.reference-grid-table tr:first-child th {
  border-top: 1px solid #dcece4;
}

.reference-grid-table tr:first-child th:first-child {
  border-top-left-radius: 8px;
}

.reference-grid-table tr:first-child th:last-child {
  border-top-right-radius: 8px;
}

.reference-grid-table tr:last-child th:first-child {
  border-bottom-left-radius: 8px;
}

.reference-grid-table tr:last-child td:last-child {
  border-bottom-right-radius: 8px;
}

.reference-grid-table thead th {
  background: var(--primary);
  color: #fff;
  display: none;
  font-weight: 800;
  min-width: 105px;
  padding: 10px 8px;
  position: sticky;
  top: 0;
  z-index: 2;
}

.reference-grid-size-row th {
  background: var(--primary);
  color: #fff;
  font-weight: 900;
  text-align: center;
  vertical-align: middle;
}

.reference-grid-size-row th:first-child {
  text-align: center;
}

.grid-size-label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0;
  line-height: 1;
  opacity: 0.82;
  text-transform: uppercase;
}

.reference-grid-table tbody th {
  background: #f6f8f4;
  color: var(--text);
  font-weight: 800;
  left: 0;
  position: sticky;
  text-align: center;
  z-index: 1;
}

.reference-grid-table th:first-child {
  min-width: 126px;
  width: 126px;
}

.grid-check,
.grid-create-cell {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 64px minmax(76px, 1fr) 64px;
  min-height: 32px;
  margin: 0 auto;
  max-width: 230px;
  width: 100%;
}

.grid-check input,
.grid-create-cell input[type="checkbox"] {
  height: 22px;
  justify-self: center;
  width: 22px;
}

.grid-initial-quantity {
  flex: 0 0 64px;
  font-size: 0.86rem;
  justify-self: end;
  max-width: 64px;
  min-height: 30px;
  min-width: 64px;
  padding: 3px 6px;
  text-align: center;
  width: 64px !important;
}

.grid-initial-quantity:disabled {
  background: #f5f7f3;
  color: #a1aa9d;
  opacity: 0.75;
}

.grid-existing-cell {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
  justify-content: center;
}

.grid-existing-main {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-columns: 64px minmax(76px, 1fr) 64px;
  margin: 0 auto;
  max-width: 230px;
  min-width: 210px;
  width: 100%;
}

.grid-cell-side {
  display: block;
  min-width: 64px;
}

.grid-existing-quantity {
  flex: 0 0 64px;
  font-size: 0.86rem;
  justify-self: end;
  max-width: 64px;
  min-height: 28px;
  min-width: 64px;
  padding: 2px 6px;
  text-align: center;
  width: 64px !important;
}

.grid-stock-badge {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

.grid-code {
  background: #e8f3ef;
  border: 1px solid #b7d9ce;
  border-radius: 6px;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  justify-self: center;
  min-width: 72px;
  padding: 6px 8px;
}

.grid-existing-main .grid-code {
  flex: 0 0 76px;
  min-width: 76px;
}

.grid-code:hover,
.grid-code:focus {
  border-color: var(--primary);
  outline: 2px solid rgba(30, 128, 105, 0.18);
}

.grid-code.is-inactive {
  background: #ffe5e5;
  border-color: #f15f5f;
  color: #b42318;
}

.grid-code.is-inactive:hover,
.grid-code.is-inactive:focus {
  border-color: #b42318;
  outline-color: rgba(180, 35, 24, 0.2);
}

.reference-product-detail {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 14px;
  padding: 12px;
}

.reference-shortcuts {
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 12px;
}

.reference-save-btn {
  margin-left: auto;
  min-width: 180px;
  padding-left: 24px;
  padding-right: 24px;
}

.reference-shortcuts .btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.inline-action-form {
  display: inline-flex;
  margin: 0;
}

.quick-entry-panel {
  display: grid;
  gap: 14px;
}

.quick-entry-search .inline-lookup {
  grid-template-columns: minmax(280px, 1fr) auto;
}

.quick-entry-product-card {
  align-items: end;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(320px, 1fr) 110px auto;
  padding: 12px;
}

.quick-entry-product-card span,
.quick-entry-not-found span {
  color: var(--muted);
  display: block;
  font-weight: 700;
  margin-top: 4px;
}

.quick-entry-table-wrap {
  max-height: min(520px, 56vh);
  overflow: auto;
}

.quick-entry-qty {
  max-width: 92px;
  text-align: center;
  width: 92px !important;
}

.quick-entry-register-modal {
  max-width: min(1180px, 96vw);
  width: min(1180px, 96vw);
}

.quick-entry-register-modal iframe {
  border: 0;
  border-radius: 8px;
  height: min(760px, 78vh);
  width: 100%;
}

.reference-product-detail-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.reference-product-detail-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
}

.reference-product-edit-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(260px, 2fr) minmax(220px, 1.4fr) repeat(4, minmax(105px, 1fr));
}

.reference-product-edit-grid .field:first-child {
  grid-column: span 2;
}

.reference-product-edit-grid .field:nth-child(2) {
  grid-column: span 2;
}

.reference-product-detail-grid span {
  background: #f8faf7;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
}

.reference-product-detail-grid b {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  margin-bottom: 2px;
}

@media (min-width: 901px) {
  body {
    font-size: 14px;
    line-height: 1.35;
  }

  .layout {
    grid-template-columns: 220px 1fr;
  }

  .sidebar {
    padding: 14px;
  }

  .sidebar .brand {
    gap: 10px;
    margin-bottom: 18px;
  }

  .brand-mark {
    height: 36px;
    width: 36px;
  }

  .nav {
    gap: 8px;
  }

  .nav-group {
    gap: 4px;
  }

  .nav-title,
  .nav a,
  .nav-inline-form button {
    padding: 7px 9px;
  }

  .nav-sub {
    margin-left: 10px;
    padding-left: 7px;
  }

  .content {
    padding: 12px 16px 16px;
  }

  .topbar {
    min-height: 54px;
    padding: 10px 16px;
  }

  h1 {
    font-size: 1.38rem;
  }

  h2 {
    font-size: 1.05rem;
    margin-bottom: 9px;
  }

  .panel {
    padding: 12px;
  }

  .grid,
  .form-grid,
  .code-fields,
  .product-detail-fields,
  .person-main-fields,
  .person-contact-fields,
  .person-extra-grid,
  .reference-grid-header,
  .reference-grid-supplier-row,
  .reference-grid-controls,
  .reference-product-edit-grid {
    gap: 9px;
  }

  .field {
    gap: 4px;
  }

  .field label {
    font-size: .78rem;
  }

  input,
  select,
  textarea {
    min-height: 30px;
    padding: 4px 8px;
  }

  textarea {
    min-height: 56px;
  }

  .btn,
  .icon-btn,
  .row-form .btn,
  .product-form > .actions .btn {
    min-height: 31px;
    padding: 5px 10px;
  }

  .actions,
  .page-actions,
  .table-actions,
  .sticky-actions,
  .sale-footer-actions,
  .sale-footer-left,
  .sale-footer-right {
    gap: 7px;
  }

  .form-title-row,
  .pos-heading {
    margin-bottom: 10px;
  }

  .metric {
    padding: 12px;
  }

  .metric strong {
    font-size: 1.32rem;
  }

  .shortcut-card {
    min-height: 108px;
    padding: 14px;
  }

  .reference-grid-wrap {
    margin-top: 10px;
    max-height: 360px;
  }

  .reference-product-detail {
    margin-top: 10px;
    padding: 10px;
  }

  .reference-shortcuts {
    margin-top: 9px;
    padding-top: 9px;
  }

  .reference-product-edit-grid {
    grid-template-columns: minmax(220px, 2fr) minmax(240px, 1.7fr) repeat(3, minmax(95px, 1fr));
  }

  .reference-product-edit-grid .field:first-child,
  .reference-product-edit-grid .field:nth-child(2) {
    grid-column: span 2;
  }
}

@media (max-width: 900px) {
  .reference-grid-header,
  .reference-grid-supplier-row,
  .reference-grid-controls,
  .reference-product-detail-grid,
  .reference-product-edit-grid {
    grid-template-columns: 1fr;
  }

  .reference-product-edit-grid .field:first-child {
    grid-column: span 1;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  body.printing-barcodes * {
    visibility: hidden !important;
  }

  body.printing-barcodes {
    background: #fff !important;
  }

  body.printing-barcodes.barcode-portrait {
    page: barcodePortrait;
  }

  body.printing-barcodes.barcode-landscape {
    page: barcodeLandscape;
  }

  body.printing-barcodes .barcode-print-sheet,
  body.printing-barcodes .barcode-print-sheet * {
    visibility: visible !important;
  }

  body.printing-barcodes .barcode-print-sheet {
    display: grid !important;
    grid-template-columns: repeat(var(--barcode-columns, 3), minmax(0, 1fr));
    gap: 4mm;
    align-items: start;
    position: fixed;
    inset: 0;
    padding: 8mm;
  }

  body.printing-barcodes.barcode-portrait .barcode-print-sheet {
    page: barcodePortrait;
    width: 210mm;
    min-height: 297mm;
  }

  body.printing-barcodes.barcode-landscape .barcode-print-sheet {
    page: barcodeLandscape;
    width: 297mm;
    min-height: 210mm;
  }

  body.printing-barcodes .barcode-label {
    width: auto;
    min-height: var(--label-height, 32mm);
    border: 0;
    box-shadow: none;
    break-inside: avoid;
    page-break-inside: avoid;
    padding: 3mm;
  }

  body.printing-barcodes .barcode-svg {
    height: var(--label-bars-height, 18mm);
  }
}

.product-status-field.is-inactive select {
  border-color: var(--danger);
  background: #fff1f0;
  color: var(--danger);
  font-weight: 900;
}

.product-detail-fields {
  display: grid;
  grid-template-columns: minmax(82px, .65fr) minmax(130px, 1fr) minmax(116px, .85fr) minmax(126px, .9fr) minmax(92px, .7fr);
  gap: 12px;
  align-items: end;
}

.product-detail-fields.has-initial-stock {
  grid-template-columns: minmax(74px, .55fr) minmax(112px, .78fr) minmax(104px, .72fr) minmax(112px, .78fr) minmax(78px, .55fr) minmax(96px, .62fr);
}

.product-name-stock-row {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(320px, 1fr) minmax(110px, 140px);
}

.product-current-stock-field input {
  background: var(--panel-soft);
  font-weight: 900;
  text-align: center;
}

.initial-stock-field input {
  text-align: center;
}

.person-main-fields {
  display: grid;
  grid-template-columns: minmax(92px, 118px) minmax(280px, 1fr);
  gap: 12px;
  align-items: end;
}

.person-code-field input {
  text-align: left;
  font-weight: 900;
}

.person-contact-fields {
  display: grid;
  grid-template-columns: minmax(140px, .7fr) minmax(160px, .8fr) minmax(230px, 1.2fr);
  gap: 12px;
  align-items: end;
}

.person-extra-fields {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px 10px;
}

.person-extra-fields summary {
  cursor: pointer;
  font-weight: 900;
  list-style-position: inside;
}

.person-extra-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(120px, .7fr) minmax(150px, .9fr) minmax(100px, .6fr) minmax(90px, .55fr) minmax(160px, 1fr) minmax(140px, .85fr) minmax(150px, .9fr) minmax(60px, .35fr);
  margin-top: 8px;
}

.person-uf-field input {
  text-align: center;
}

.person-notes-field textarea,
.product-notes-field textarea {
  min-height: 42px;
  resize: vertical;
}

.person-flags {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
}

.person-flags .check-row {
  min-height: 38px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 8px 10px;
}

.person-blocked-check.is-blocked {
  border-color: var(--danger);
  background: #fff1f0;
  color: var(--danger);
  font-weight: 900;
}

.form-audit {
  color: var(--muted);
  display: grid;
  gap: 3px;
  font-size: .84rem;
  font-weight: 700;
  justify-self: end;
  text-align: right;
}

.product-suppliers-box {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 9px 10px;
}

.product-suppliers-box .form-title-row {
  margin-bottom: 0;
}

.product-suppliers-box .form-title-row h2 {
  font-size: 1rem;
}

.compact-table {
  min-width: 760px;
}

.supplier-code-col {
  width: 190px;
}

.supplier-name-col {
  width: 38%;
}

.supplier-barcode-col {
  width: 28%;
}

.supplier-actions-col {
  width: 180px;
}

.supplier-code-cell {
  grid-template-columns: minmax(70px, 1fr) auto;
}

.compact-table th,
.compact-table td {
  padding: 5px 7px;
}

.compact-table input,
.compact-table select {
  min-height: 28px;
  padding-bottom: 4px;
  padding-top: 4px;
}

.inline-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.compact-table .inline-actions .btn {
  min-height: 30px;
  padding: 4px 8px;
}

.compact-field input,
.compact-field select,
.money-field input {
  min-height: 30px;
}

.compact-field input,
.money-field input {
  text-align: center;
}

[data-uppercase] {
  text-transform: uppercase;
}

.field {
  display: grid;
  gap: 6px;
}

.field-full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-weight: 700;
  font-size: .76rem;
}

.inline-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.icon-btn {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 800;
  padding: 0 8px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-size: .95rem;
  min-height: 30px;
  padding: 4px 8px;
}

textarea {
  min-height: 56px;
  resize: vertical;
}

.product-picker {
  gap: 8px;
}

.product-picker input[type="search"] {
  background: var(--panel-soft);
}

.product-list {
  min-height: 178px;
  padding: 6px;
}

.product-list option {
  border-radius: 6px;
  padding: 8px 10px;
}

.product-list option:checked {
  background: var(--accent);
  color: #fff;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.form-grid > .actions {
  grid-column: 1 / -1;
}

.product-form > .actions .btn {
  min-height: 30px;
  padding: 4px 8px;
}

.row-form {
  display: grid;
  grid-template-columns: 110px minmax(180px, 1fr) auto;
  gap: 8px;
  min-width: 420px;
}

.row-form input {
  min-height: 30px;
}

.row-form .btn {
  min-height: 30px;
  padding: 4px 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 31px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: .92rem;
  font-weight: 800;
  padding: 4px 10px;
}

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

.btn.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

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

.alert {
  border-radius: var(--radius);
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.alert.error {
  border-color: #f1b8b3;
  background: #fff4f2;
  color: var(--danger);
}

.alert.success {
  border-color: #a7d8c7;
  background: #f0fbf6;
  color: #0f684e;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: .82rem;
  text-transform: uppercase;
}

.selectable-table tbody tr {
  cursor: pointer;
}

.selectable-table tbody tr:hover > td {
  background: var(--panel-soft);
}

.selectable-table tbody tr:focus {
  outline: none;
}

.selectable-table tbody tr.is-selected > td,
.selectable-table tbody tr:focus > td {
  background: #f1faf5;
  border-bottom-color: rgba(22, 116, 95, .4);
  box-shadow: inset 0 2px 0 rgba(22, 116, 95, .72), inset 0 -2px 0 rgba(22, 116, 95, .72);
}

.selectable-table tbody tr.is-selected > td:first-child,
.selectable-table tbody tr:focus > td:first-child {
  box-shadow: inset 2px 0 0 rgba(22, 116, 95, .72), inset 0 2px 0 rgba(22, 116, 95, .72), inset 0 -2px 0 rgba(22, 116, 95, .72);
}

.selectable-table tbody tr.is-selected > td:last-child,
.selectable-table tbody tr:focus > td:last-child {
  box-shadow: inset -2px 0 0 rgba(22, 116, 95, .72), inset 0 2px 0 rgba(22, 116, 95, .72), inset 0 -2px 0 rgba(22, 116, 95, .72);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #edf3ec;
  color: #31513d;
  font-size: .82rem;
  font-weight: 800;
  padding: 3px 9px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #edf3ec;
  color: #31513d;
  font-size: .82rem;
  font-weight: 800;
  min-height: 24px;
  padding: 3px 9px;
}

.badge.warning {
  background: #fff4e5;
  color: var(--warning);
}

.badge.danger,
.status-badge.danger {
  background: #fff1f0;
  color: var(--danger);
}

.status-badge.success {
  background: #f0fbf6;
  color: #0f684e;
}

.status-badge.warning {
  background: #fff4e5;
  color: var(--warning);
}

.status-badge.neutral {
  background: #eef1ec;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 18px;
  margin-top: 12px;
}

.detail-grid span {
  color: var(--muted);
}

.detail-grid strong {
  color: var(--text);
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    max-height: none;
    overflow: visible;
    position: static;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .nav-session {
    grid-column: 1 / -1;
  }

  .metrics,
  .split,
  .pos-shell,
  .sale-workspace,
  .report-grid,
  .form-row {
    grid-template-columns: 1fr;
  }

  .sale-header-card,
  .sale-item-card,
  .sale-items-card,
  .sale-close-card {
    grid-column: auto;
    grid-row: auto;
  }

  .sale-close-card {
    position: static;
  }

  .code-fields {
    grid-template-columns: 1fr;
  }

  .product-detail-fields {
    grid-template-columns: 1fr;
  }

  .product-name-stock-row {
    grid-template-columns: 1fr;
  }

  .person-main-fields,
  .person-contact-fields,
  .person-extra-grid,
  .person-flags,
  .sale-customer-row,
  .sale-transaction-row,
  .sale-meta-row,
  .sale-scan-row,
  .sale-scan-row-bottom,
  .sale-item-row,
  .sale-item-adjust-row,
  .sale-close-grid,
  .stock-filter-row.product-row,
  .stock-filter-row.supplier-row,
  .stock-filter-row.detail-row,
  .balance-filter-row-main,
  .balance-filter-row-secondary,
  .balance-filter-row-actions {
    grid-template-columns: 1fr;
  }

  .stock-filter-actions,
  .stock-filter-actions .btn {
    width: 100%;
  }

  .stock-filter-options {
    grid-template-columns: 1fr;
  }

  .pos-grid,
  .checkout-grid,
  .filters,
  .detail-grid,
  .row-form {
    grid-template-columns: 1fr;
  }

  .pos-heading {
    flex-direction: column;
  }

  .form-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .pos-total {
    width: 100%;
    text-align: left;
  }

  .inline-search {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .content {
    padding: 14px;
  }

  .btn,
  .icon-btn,
  input,
  select,
  textarea {
    min-height: 40px;
  }

  .page-actions,
  .table-actions,
  .sticky-actions,
  .actions,
  .report-actions,
  .sale-footer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .page-actions .btn,
  .table-actions .btn,
  .sticky-actions .btn,
  .actions .btn,
  .report-actions .btn,
  .sale-footer-actions .btn {
    width: 100%;
  }
}

@media print {
  @page {
    size: landscape;
    margin: 10mm;
  }

  body {
    background: #fff;
    font-size: 11px;
  }

  .sidebar,
  .topbar,
  .report-section,
  .report-actions,
  .receipt-actions,
  dialog,
  .alert {
    display: none !important;
  }

  .layout {
    display: block;
  }

  .content {
    padding: 0;
  }

  .panel,
  .table-wrap {
    border: 0;
    box-shadow: none;
  }

  .stock-table-wrap {
    overflow: visible;
  }

  .stock-table {
    min-width: 0;
    table-layout: auto;
    width: 100%;
  }

  .stock-table th:last-child,
  .stock-table td:last-child {
    display: none;
  }

  .stock-table thead th {
    background: #16745f !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .selectable-table tbody tr.is-selected > td,
  .selectable-table tbody tr:focus > td,
  .selectable-table tbody tr.is-selected > td:first-child,
  .selectable-table tbody tr:focus > td:first-child,
  .selectable-table tbody tr.is-selected > td:last-child,
  .selectable-table tbody tr:focus > td:last-child {
    background: transparent;
    box-shadow: none;
  }

  .receipt {
    max-width: 100%;
  }

  .receipt-paper {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
}

/* AJUSTE COMBINADO SEGURO - VENDA E PAGAMENTO
   Escopo: somente lista de itens da venda e campos de pagamento.
   Não altera regras de negócio, banco, PHP, estoque ou transações.
*/

/* Aumenta o quadro/lista de produtos na tela Saída/Venda */
.sale-items-wrap {
  height: clamp(210px, 34vh, 470px);
  max-height: 50vh;
}

/* Compacta as linhas da lista para caber mais produto na tela */
.sale-items-table th,
.sale-items-table td {
  padding-top: 2px;
  padding-bottom: 2px;
  line-height: 1.02;
}

.sale-items-table tbody td {
  line-height: 1.02;
}

/* Campo de quantidade dentro da lista mais baixo */
.sale-items-table .line-qty-input,
.sale-items-table .line-price-input,
.line-qty-input {
  min-height: 22px;
  padding-top: 1px;
  padding-bottom: 1px;
}

.sale-items-table .line-price-input {
  max-width: 110px;
}

/* Botão remover dentro da tabela mais compacto sem afetar botões gerais */
.sale-items-table .btn {
  min-height: 26px;
  padding-top: 3px;
  padding-bottom: 3px;
}

.sale-notes-modal textarea {
  min-height: 180px;
  resize: vertical;
  width: 100%;
}

/* Corrige sobreposição entre Data do primeiro pagamento e Parcelas */
@media (min-width: 901px) {
  .payment-shell .checkout-grid {
    grid-template-columns:
      minmax(150px, .7fr)
      minmax(240px, 1fr)
      minmax(135px, .55fr)
      minmax(145px, .6fr);
    column-gap: 18px;
    row-gap: 10px;
  }

  .payment-shell .checkout-grid .field {
    min-width: 0;
  }

  .payment-shell .checkout-grid input,
  .payment-shell .checkout-grid select {
    min-width: 0;
  }

  .payment-shell .installment-date-input {
    max-width: none;
    width: 100%;
  }
}

/* Em telas menores, empilha para evitar qualquer sobreposição */
@media (max-width: 900px) {
  .payment-shell .checkout-grid {
    grid-template-columns: 1fr;
  }
}

/* AJUSTE SEGURO - CADASTRO DE PRODUTOS: busca ao lado dos campos */
.product-code-fields {
  grid-template-columns: minmax(230px, 270px) minmax(250px, 1fr) minmax(260px, 1fr) minmax(130px, 160px);
}

.product-code-lookup-field .inline-search,
.product-reference-lookup-field .inline-search {
  grid-template-columns: minmax(0, 1fr) auto;
}

.product-code-lookup-field .btn,
.product-reference-lookup-field .btn {
  white-space: nowrap;
}

@media (max-width: 900px) {
  .product-code-fields {
    grid-template-columns: 1fr;
  }
}


/* AJUSTE SEGURO - ENTRADA/COMPRA
   Escopo: somente tela de compra. Não altera venda, estoque, financeiro ou cadastro.
*/
.purchase-entry {
  display: grid;
  gap: 8px;
}

.purchase-transaction-row {
  display: grid;
  grid-template-columns: minmax(120px, 170px) minmax(150px, 210px) minmax(150px, 190px) minmax(240px, 1fr) minmax(130px, 160px);
  gap: 8px;
  align-items: end;
}

.purchase-supplier-row {
  display: grid;
  grid-template-columns: minmax(130px, 180px) minmax(360px, 1fr);
  gap: 10px;
  align-items: end;
}

.purchase-transaction-code input,
.purchase-supplier-code input {
  font-weight: 900;
  text-align: right;
}

.purchase-status-field {
  justify-items: end;
  justify-self: end;
}

.purchase-status-field .status-badge {
  justify-content: center;
  min-height: 31px;
  width: 100%;
}

.purchase-cart-panel {
  display: grid;
  gap: 6px;
}

.purchase-items-wrap {
  height: clamp(210px, 29vh, 450px);
  min-height: 0;
  max-height: 47vh;
  padding: 0;
}

.purchase-items-wrap .cart-list {
  display: block;
  margin-bottom: 0;
  max-height: none;
}

.purchase-items-wrap .compact-table {
  min-width: 920px;
  table-layout: fixed;
}

.purchase-items-wrap .compact-table th:nth-child(1),
.purchase-items-wrap .compact-table td:nth-child(1) {
  width: 88px;
}

.purchase-items-wrap .compact-table th:nth-child(2),
.purchase-items-wrap .compact-table td:nth-child(2) {
  width: auto;
}

.purchase-items-wrap .compact-table th:nth-child(3),
.purchase-items-wrap .compact-table td:nth-child(3) {
  width: 62px;
}

.purchase-items-wrap .compact-table th:nth-child(4),
.purchase-items-wrap .compact-table td:nth-child(4) {
  width: 86px;
}

.purchase-items-wrap .compact-table th:nth-child(5),
.purchase-items-wrap .compact-table td:nth-child(5) {
  width: 70px;
}

.purchase-items-wrap .compact-table th:nth-child(6),
.purchase-items-wrap .compact-table td:nth-child(6) {
  width: 104px;
}

.purchase-items-wrap .compact-table th:nth-child(7),
.purchase-items-wrap .compact-table td:nth-child(7) {
  width: 112px;
}

.purchase-items-wrap .compact-table th:nth-child(8),
.purchase-items-wrap .compact-table td:nth-child(8) {
  width: 104px;
}

.purchase-items-wrap .compact-table th,
.purchase-items-wrap .compact-table td {
  padding-top: 2px;
  padding-bottom: 2px;
  line-height: 1.02;
  vertical-align: middle;
}

.purchase-items-wrap .table-input {
  max-width: 74px;
  min-height: 24px;
  padding-top: 2px;
  padding-bottom: 2px;
}

.purchase-items-wrap [data-change-purchase-cost] {
  max-width: 92px;
}

.purchase-items-wrap .btn {
  min-height: 26px;
  padding-top: 3px;
  padding-bottom: 3px;
}

.purchase-scan-row-bottom {
  display: grid;
  grid-template-columns: minmax(210px, 330px) minmax(260px, 1fr) minmax(130px, auto);
  gap: 8px;
  align-items: end;
  border-top: 1px solid var(--line);
  margin-bottom: 0;
  margin-top: 4px;
  padding-top: 8px;
}

.purchase-totals-grid {
  display: grid;
  grid-template-columns: 88px 88px 102px 118px minmax(135px, 170px) minmax(145px, 1fr) minmax(118px, 145px) 76px;
  gap: 8px;
  align-items: end;
  margin-bottom: 0;
}

.purchase-totals-grid .sale-inline-total {
  min-height: 31px;
  padding-block: 3px;
}

.purchase-cart-panel > .field {
  margin-top: -2px;
}

.purchase-cart-panel > .field input[name="notes"] {
  min-height: 30px;
}

.purchase-cart-panel .sale-footer-actions {
  margin-top: 4px;
}

@media (max-width: 900px) {
  .purchase-transaction-row,
  .purchase-supplier-row,
  .purchase-scan-row-bottom,
  .purchase-totals-grid {
    grid-template-columns: 1fr;
  }

  .purchase-status-field {
    justify-items: stretch;
    justify-self: stretch;
  }
}

/* AJUSTE SEGURO - BALANCO - FILTRO COM UMA ROLAGEM
   Escopo: somente tela de Balanço.
   Objetivo: reduzir altura do filtro e deixar a rolagem principal na lista de produtos.
*/
.content:has(.balance-page-shell) {
  height: calc(100vh - 54px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.content:has(.balance-page-shell) .balance-page-shell {
  flex: 1;
  min-height: 0;
}

.balance-page-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

.balance-filter-panel {
  margin-top: 0;
  padding: 10px 12px;
}

.balance-filter-form {
  gap: 8px;
}

.balance-filter-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 2px;
}

.balance-filter-head h2 {
  margin: 0;
}

.balance-filter-options {
  display: flex;
  gap: 8px;
  grid-template-columns: none;
  width: auto;
}

.balance-filter-options .check-row {
  font-size: .78rem;
  min-height: 30px;
  padding: 4px 8px;
}

.balance-filter-options .check-row input {
  min-height: 16px;
  width: 16px;
}

.balance-filter-row-main {
  grid-template-columns: minmax(110px, 140px) minmax(110px, 140px) minmax(150px, 180px) minmax(340px, 1fr);
}

.balance-filter-row-secondary {
  grid-template-columns: minmax(340px, 1.2fr) minmax(160px, 200px) minmax(120px, 160px) minmax(170px, 210px) minmax(130px, 170px);
}

.balance-product-name input,
.balance-references-field input {
  min-width: 0;
}

.balance-frame {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  margin-top: 0;
  min-height: 0;
  overflow: hidden;
  padding: 10px 12px;
}

.balance-frame .stock-report-head {
  margin-bottom: 4px;
}

.balance-table-wrap {
  height: 100%;
  max-height: none;
  min-height: 0;
  overflow: auto;
}

.balance-table th,
.balance-table td {
  padding-bottom: 4px;
  padding-top: 4px;
}

.balance-table input {
  min-height: 28px;
}

.balance-frame .report-actions {
  margin-top: 8px;
}

.balance-important-panel {
  padding: 10px 12px;
}

@media (max-width: 900px) {
  .content:has(.balance-page-shell) {
    height: auto;
    overflow: visible;
  }

  .balance-page-shell {
    display: grid;
    overflow: visible;
  }

  .balance-filter-head,
  .balance-filter-options {
    align-items: stretch;
    flex-direction: column;
  }

  .balance-filter-row-main,
  .balance-filter-row-secondary {
    grid-template-columns: 1fr;
  }

  .balance-frame {
    overflow: visible;
  }

  .balance-table-wrap {
    max-height: 62vh;
  }
}

/* AJUSTE FINAL SEGURO - BALANCO COMPACTO E UMA ROLAGEM
   Escopo: somente a tela de Balanço.
   Objetivo: checks pequenos no topo, filtro mais baixo, linhas compactas e rolagem principal na lista.
*/
body:has(.balance-page-shell) {
  overflow: hidden;
}

.main:has(.balance-page-shell) {
  height: 100vh;
  overflow: hidden;
}

.content:has(.balance-page-shell) {
  height: calc(100vh - 54px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 8px;
}

.content:has(.balance-page-shell) .balance-page-shell {
  flex: 1;
  min-height: 0;
}

.balance-page-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 6px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.balance-filter-panel {
  margin-top: 0;
  padding: 8px 10px;
}

.balance-filter-form {
  gap: 6px;
}

.balance-filter-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 0 0 5px;
}

.balance-filter-head h2 {
  font-size: 1rem;
  line-height: 1.05;
  margin: 0;
}

.balance-filter-options {
  display: flex !important;
  flex-wrap: nowrap;
  gap: 12px;
  grid-template-columns: none !important;
  margin-left: auto;
  width: auto !important;
}

.balance-filter-options .check-row {
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  font-size: .72rem;
  gap: 5px;
  min-height: 0;
  padding: 0;
  white-space: nowrap;
}

.balance-filter-options .check-row input {
  height: 14px;
  min-height: 14px;
  width: 14px;
}

.balance-filter-panel .inline-label {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.balance-filter-panel .inline-check {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: .68rem;
  gap: 4px;
  white-space: nowrap;
}

.balance-filter-panel .inline-check input {
  height: 13px;
  min-height: 13px;
  width: 13px;
}

.balance-filter-row {
  gap: 6px;
}

.balance-filter-panel .field {
  gap: 2px;
}

.balance-filter-panel .field label {
  font-size: .68rem;
  line-height: 1.05;
}

.balance-filter-panel input,
.balance-filter-panel .btn {
  min-height: 27px;
  padding-bottom: 3px;
  padding-top: 3px;
}

.balance-filter-row-main {
  grid-template-columns: minmax(190px, .9fr) 95px 95px 145px minmax(210px, 1.15fr);
}

.balance-filter-row-secondary {
  grid-template-columns: minmax(210px, .9fr) 155px 105px 165px 120px;
}

.balance-product-search-btn,
.balance-reference-search-btn,
.balance-supplier-search-btn,
.balance-submit-btn {
  min-height: 27px;
  padding-left: 8px;
  padding-right: 8px;
}

.balance-frame {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 5px;
  margin-top: 0;
  min-height: 0;
  overflow: hidden;
  padding: 8px 10px;
}

.balance-frame .stock-report-head {
  margin-bottom: 0;
}

.balance-frame .stock-report-head h2 {
  font-size: .98rem;
  margin: 0;
}

.balance-frame .stock-report-head .muted {
  font-size: .82rem;
}

.balance-table-wrap {
  height: 100%;
  max-height: none;
  min-height: 0;
  overflow: auto;
}

.balance-table th,
.balance-table td {
  line-height: 1.04;
  padding: 2px 6px;
}

.balance-table input {
  min-height: 24px;
  padding-bottom: 2px;
  padding-top: 2px;
}

.balance-table .table-input {
  min-height: 24px;
  padding-bottom: 2px;
  padding-top: 2px;
}

.balance-table th:nth-child(1) { width: 92px; }
.balance-table th:nth-child(2) { width: 360px; }
.balance-table th:nth-child(3) { width: 105px; }
.balance-table th:nth-child(4) { width: 130px; }
.balance-table th:nth-child(5) { width: 250px; }

.balance-frame .report-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.balance-frame .report-actions .btn {
  min-height: 28px;
  padding-bottom: 4px;
  padding-top: 4px;
}

.balance-zero-uncounted {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--muted);
  display: inline-flex;
  font-size: .78rem;
  gap: 6px;
  min-height: 28px;
  padding: 0;
  white-space: nowrap;
}

.balance-zero-uncounted input {
  height: 15px;
  min-height: 15px;
  width: 15px;
}

.balance-important-panel {
  font-size: .86rem;
  padding: 7px 10px;
}

@media (max-width: 900px) {
  body:has(.balance-page-shell),
  .main:has(.balance-page-shell),
  .content:has(.balance-page-shell) {
    height: auto;
    overflow: visible;
  }

  .balance-page-shell {
    height: auto;
    overflow: visible;
  }

  .balance-filter-head,
  .balance-filter-options {
    align-items: flex-start;
    flex-direction: column;
  }

  .balance-filter-row-main,
  .balance-filter-row-secondary {
    grid-template-columns: 1fr;
  }

  .balance-frame {
    overflow: visible;
  }

  .balance-table-wrap {
    max-height: 62vh;
  }
}

/* AJUSTE PROFISSIONAL DE DENSIDADE - CADASTROS */
.product-form {
  gap: 8px 10px;
  padding: 10px 12px;
}

.product-form .form-title-row {
  gap: 8px;
  margin-bottom: 0;
}

.product-form .form-title-row h2 {
  font-size: 1rem;
  margin: 0;
}

.product-form .field,
.person-main-fields .field,
.person-contact-fields .field,
.person-extra-fields .field,
.reference-grid-panel .field,
.stock-filter-form .field,
.balance-filter-panel .field {
  gap: 3px;
}

.product-form .field label,
.person-main-fields label,
.person-contact-fields label,
.person-extra-fields label,
.person-notes-field label,
.reference-grid-panel label,
.stock-filter-form label,
.balance-filter-panel label {
  font-size: .72rem;
  line-height: 1.05;
}

.product-form input,
.product-form select,
.product-form textarea,
.product-form .btn,
.person-main-fields input,
.person-contact-fields input,
.person-extra-fields input,
.person-extra-fields select,
.person-notes-field textarea,
.reference-grid-panel input,
.reference-grid-panel select,
.reference-grid-panel .btn,
.stock-filter-form input,
.stock-filter-form select,
.stock-filter-form .btn,
.balance-filter-panel input,
.balance-filter-panel select,
.balance-filter-panel .btn {
  min-height: 30px;
  padding-bottom: 4px;
  padding-top: 4px;
}

.product-form .product-code-fields,
.product-form .product-name-stock-row,
.product-form .product-detail-fields,
.person-main-fields,
.person-contact-fields,
.person-extra-grid,
.reference-grid-header,
.reference-grid-supplier-row,
.reference-grid-controls,
.stock-filter-form,
.stock-filter-row,
.balance-filter-form,
.balance-filter-row {
  gap: 8px;
}

.product-form .product-current-stock-field input,
.product-form .initial-stock-field input {
  max-width: 110px;
}

.product-notes-field textarea,
.person-notes-field textarea {
  height: 34px;
  line-height: 1.2;
  min-height: 34px;
  resize: vertical;
}

.product-suppliers-box {
  gap: 6px;
  margin-top: 0;
  padding: 7px 8px;
}

.product-suppliers-box .form-title-row {
  margin-bottom: 2px;
}

.product-suppliers-box .form-title-row h2 {
  font-size: .92rem;
}

.product-suppliers-box .table-wrap {
  max-height: 132px;
  overflow: auto;
}

.product-suppliers-box table th,
.product-suppliers-box table td,
.product-suppliers-box .compact-table th,
.product-suppliers-box .compact-table td {
  line-height: 1.1;
  padding: 4px 5px;
}

.product-suppliers-box input,
.product-suppliers-box .btn,
.product-suppliers-box button {
  min-height: 28px;
  padding-bottom: 3px;
  padding-top: 3px;
}

.person-main-fields .person-code-field {
  max-width: 145px;
}

.person-extra-fields {
  padding: 6px 8px;
}

.person-extra-fields summary {
  min-height: 26px;
  padding: 2px 0;
}

.person-extra-grid {
  margin-top: 6px;
}

.person-flags {
  gap: 6px;
}

.person-flags .check-row {
  min-height: 30px;
  padding: 5px 8px;
}

.reference-grid-panel {
  padding: 10px 12px;
}

.reference-grid-controls {
  margin-top: 8px;
}

.reference-grid-wrap {
  margin-top: 10px;
  max-height: min(48vh, 390px);
}

.reference-grid-table th,
.reference-grid-table td {
  padding: 6px;
}

.reference-grid-table thead th,
.reference-grid-size-row th {
  padding: 7px 6px;
}

.grid-check,
.grid-create-cell {
  gap: 6px;
  min-height: 30px;
}

.grid-initial-quantity {
  min-height: 28px;
}

.reference-product-detail,
.reference-product-detail-grid {
  gap: 8px;
}

.stock-report-frame,
.balance-filter-panel,
.balance-frame {
  gap: 8px;
  padding: 8px 10px;
}

.stock-filter-form {
  margin-bottom: 10px;
}

.stock-filter-options,
.balance-filter-options {
  gap: 6px;
}

.stock-filter-options .check-row,
.balance-filter-options .check-row {
  min-height: 30px;
  padding: 5px 8px;
}

.stock-table th,
.stock-table td,
.balance-table th,
.balance-table td {
  line-height: 1.08;
  padding: 3px 6px;
}

.stock-table input,
.balance-table input {
  min-height: 26px;
  padding-bottom: 2px;
  padding-top: 2px;
}

.stock-table-wrap,
.balance-table-wrap {
  scrollbar-gutter: stable;
}

/* PARAMETROS DA LOJA */
.settings-panel {
  display: grid;
  gap: 10px;
}

.settings-title-row {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.settings-title-row h2 {
  margin: 0;
}

.settings-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-block {
  align-content: start;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 8px;
  padding: 10px;
}

.settings-block h3 {
  font-size: .96rem;
  margin: 0;
}

.settings-block .field {
  gap: 3px;
}

.settings-block input,
.settings-block select {
  min-height: 32px;
  padding-bottom: 4px;
  padding-top: 4px;
}

.settings-block .btn {
  min-height: 32px;
  padding-bottom: 5px;
  padding-top: 5px;
}

.settings-check-list {
  display: grid;
  gap: 6px;
}

.settings-block .check-row {
  background: #fff;
  min-height: 32px;
  padding: 5px 8px;
}

.settings-customer-row {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(88px, 120px) auto minmax(180px, 1fr);
}

.settings-block-security {
  grid-column: 1 / -1;
}

@media (max-width: 920px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-customer-row {
    grid-template-columns: 1fr;
  }
}

/* PAGAMENTO DA VENDA - RESUMO E PARCELAS */
.payment-summary {
  background: #f7faf6;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 8px;
  padding: 10px;
}

.payment-summary-row {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.payment-summary-row strong {
  white-space: nowrap;
}

.payment-summary-row.is-danger {
  color: #b42318;
}

.payment-summary-warning,
.payment-consumer-warning {
  font-size: .9rem;
  margin: 8px 0;
  padding: 8px 10px;
}

.payment-change-box {
  background: #eaf7ef;
  border-color: #b6dfc4;
  color: #11613a;
  font-weight: 800;
}

.payment-installments-table {
  margin-top: 8px;
}

.payment-shell .installments-frame {
  min-height: 92px;
}

.payment-shell .installments-frame.is-disabled {
  background: #f7faf6;
  color: var(--muted);
}

.payment-installments-table th,
.payment-installments-table td {
  padding: 6px 8px;
}

.payment-installments-table .installment-date-input,
.payment-installments-table .installment-amount-input {
  min-height: 32px;
  padding-bottom: 4px;
  padding-top: 4px;
}

@media (max-width: 920px) {
  .payment-summary {
    grid-template-columns: 1fr;
  }
}
