:root {
  --excel-green: #217346;
  --excel-green-dark: #185c37;
  --excel-green-light: #e2efda;
  --excel-ribbon: #f3f3f3;
  --excel-border: #d4d4d4;
  --excel-border-dark: #ababab;
  --excel-header: #f2f2f2;
  --excel-header-text: #333;
  --excel-cell: #fff;
  --excel-text: #000;
  --excel-muted: #595959;
  --excel-select: #cce8cf;
  --excel-total: #fff2cc;
  --excel-landing: #c6efce;
  --font: "Segoe UI", Calibri, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 11pt;
  line-height: 1.35;
  color: var(--excel-text);
  background: #e8e8e8;
  padding-bottom: 6.5rem;
  overflow-x: hidden;
  max-width: 100%;
}

body.login-page {
  padding-bottom: 0;
}

body.sheet-landing {
  padding-bottom: 2.75rem;
}

body.sheet-seller {
  padding-bottom: 2.75rem;
}

body.sheet-lotsales {
  padding-bottom: 2.75rem;
}

body.sheet-brands {
  padding-bottom: 2.75rem;
}

body.sheet-summary {
  padding-bottom: 2.75rem;
}

.excel-app {
  max-width: 1100px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--excel-border-dark);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

/* Title bar */
.excel-titlebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  background: var(--excel-green);
  color: #fff;
}

.titlebar-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.excel-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  background: #fff;
  color: var(--excel-green);
  font-weight: 700;
  font-size: 1rem;
  border-radius: 2px;
}

.workbook-name {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
}

.workbook-sub {
  display: block;
  font-size: 0.7rem;
  opacity: 0.85;
}

.titlebar-rate {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  padding: 0.35rem 0.6rem;
  border-radius: 2px;
  white-space: nowrap;
}

.titlebar-rate label,
.titlebar-rate span {
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}

.titlebar-rate input {
  width: 5.5rem;
  padding: 0.15rem 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: right;
  caret-color: #fff;
}

.titlebar-rate input:focus {
  outline: 2px solid rgba(255, 255, 255, 0.65);
  outline-offset: 0;
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
}

/* Ribbon */
.excel-ribbon {
  padding: 0.35rem 0.75rem;
  background: var(--excel-ribbon);
  border-bottom: 1px solid var(--excel-border);
}

.ribbon-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.ribbon-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 3.5rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  font-family: var(--font);
  font-size: 0.65rem;
  color: var(--excel-text);
  cursor: pointer;
}

.ribbon-btn:hover {
  background: #e1e1e1;
  border-color: var(--excel-border);
}

.ribbon-btn-primary {
  background: var(--excel-green-light);
  border-color: #a9d18e;
}

.ribbon-icon {
  font-size: 1rem;
  line-height: 1;
}

.ribbon-btn.calculator-only {
  display: none;
}

body.sheet-calculator .ribbon-btn.calculator-only {
  display: inline-flex;
}

/* Sheet area */
.workbook-panes {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.workbook-pane {
  flex: 1;
}

.workbook-pane.hidden {
  display: none !important;
}

.excel-sheet {
  flex: 1;
  padding: 0.5rem;
  background: #fff;
  overflow-x: auto;
}

.sheet-section-full {
  width: 100%;
}

.sections-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: start;
}

.sections-grid .sheet-section {
  margin-bottom: 0;
  min-width: 0;
}

.sections-grid .sheet-section-wide {
  grid-column: 1 / -1;
}

.sheet-section {
  margin-bottom: 0.75rem;
}

.sheet-section.nested {
  margin-bottom: 0.65rem;
  padding-left: 0.25rem;
  border-left: 3px solid var(--excel-green);
}

.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--excel-green-dark);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.section-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
}

#alibabaPanel {
  margin-top: 0.75rem;
}

#alibabaGstNote {
  margin-top: 0.75rem;
}

.sheet-note {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.72rem;
  color: var(--excel-muted);
  font-style: italic;
}

/* Grid tables */
.grid-wrap {
  overflow-x: auto;
  border: 1px solid var(--excel-border);
}

.grid-wrap-full {
  width: 100%;
}

.grid-wrap-full .calc-table {
  width: 100%;
  table-layout: auto;
}

#productTable th.col-product-name {
  text-align: left;
}

#productTable th:nth-child(2),
#productTable td:nth-child(2) {
  width: 100%;
  min-width: 10rem;
}

#productTable .col-qty {
  width: 4.25rem;
  min-width: 4.25rem;
  max-width: 4.25rem;
  white-space: nowrap;
}

#productTable .product-qty {
  width: 100%;
  box-sizing: border-box;
  text-align: right;
}

.sheet-kv {
  width: 100%;
  border-collapse: collapse;
  font-size: 11pt;
  table-layout: fixed;
}

.calc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11pt;
}

.calc-table th,
.calc-table td,
.sheet-kv td {
  border: 1px solid var(--excel-border);
  padding: 0.2rem 0.4rem;
  vertical-align: middle;
  background: var(--excel-cell);
}

.calc-table th {
  background: var(--excel-header);
  font-weight: 600;
  font-size: 10pt;
  color: var(--excel-header-text);
  text-align: center;
  white-space: nowrap;
}

.col-row-num {
  width: 2rem;
  min-width: 2rem;
  text-align: center !important;
  background: var(--excel-header) !important;
  color: var(--excel-muted);
  font-size: 9pt;
}

.calc-table td.col-row-num {
  background: var(--excel-header) !important;
  font-size: 9pt;
  color: var(--excel-muted);
}

.calc-table td:nth-child(n+3) {
  text-align: right;
}

.calc-table td:first-child + td {
  text-align: left;
}

.calc-table tbody tr:hover td:not(.col-row-num) {
  background: #fafafa;
}

.calc-table tfoot td {
  background: var(--excel-total);
  font-weight: 600;
}

.row-total .label-cell {
  text-align: right;
  color: var(--excel-muted);
  font-size: 10pt;
}

.sheet-kv .cell-label {
  width: 55%;
  background: var(--excel-header);
  color: var(--excel-text);
  font-size: 10pt;
}

.sheet-kv .cell-value,
.sheet-kv .cell-input {
  text-align: right;
  padding-right: 0.55rem;
}

.sheet-kv .cell-input input[type="number"] {
  padding-right: 0.15rem;
}

.sheet-kv .cell-value strong {
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.row-highlight td {
  background: #f9f9f9;
}

.row-highlight .cell-value strong,
.cell-inr strong {
  font-weight: 600;
  color: var(--excel-green-dark);
}

.row-total-line td {
  background: var(--excel-total);
  font-weight: 600;
}

.row-landing-total td {
  background: var(--excel-landing);
  font-weight: 700;
  font-size: 1.15rem;
  padding: 0.85rem 1rem;
  border: 2px solid var(--excel-green-dark) !important;
}

.row-landing-per-piece td {
  background: #f3faf3;
  font-weight: 600;
}

.landing-total-section .landing-breakdown .cell-label {
  font-size: 10pt;
}

.sheet-note-inline {
  margin: 0;
  font-size: 0.8rem;
  color: var(--excel-muted);
  font-style: italic;
}

.row-landing-total .cell-label {
  font-size: 1.15rem;
  font-weight: 700;
}

.row-landing-total .cell-value strong {
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--excel-green-dark);
}

.col-action {
  width: 4.5rem;
  min-width: 4.5rem;
  text-align: center !important;
  padding: 0.35rem 0.5rem !important;
  white-space: nowrap;
}

.calc-table th.col-action {
  font-size: 10pt;
  font-weight: 600;
}

.calc-table td.col-action {
  padding: 0.35rem 0.5rem !important;
}

.cell-readonly {
  font-variant-numeric: tabular-nums;
}

/* Inputs — borderless in cells like Excel */
input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 0.2rem 0.35rem;
  border: none;
  border-radius: 0;
  font-family: var(--font);
  font-size: 11pt;
  color: var(--excel-text);
  background: transparent;
  text-align: inherit;
  box-sizing: border-box;
}

input[type="number"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding-right: 0.5rem;
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.titlebar-rate input[type="number"] {
  padding: 0.15rem 0.45rem 0.15rem 0.35rem;
  color: #fff;
  -webkit-text-fill-color: #fff;
}

input:focus {
  outline: 2px solid var(--excel-green);
  outline-offset: -2px;
  background: #fff;
}

.calc-table input {
  min-width: 0;
}

.calc-table td:nth-child(n+3):not(.col-action) {
  padding-right: 0.55rem;
}

.calc-table .product-qty,
.calc-table .seller-price {
  padding-right: 0.5rem;
}

.calc-table .product-name {
  text-align: left;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}

.btn-remove {
  width: 1.5rem;
  height: 1.5rem;
  min-height: 1.4rem;
  padding: 0;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #c00000;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

.btn-remove:hover {
  background: #fce4e4;
}

/* Mode switches — Excel toggle style */
.mode-switch,
.weight-unit-switch,
.payment-type-switch {
  display: inline-flex;
  border: 1px solid var(--excel-border-dark);
  background: #fff;
}

.mode-btn,
.unit-btn,
.payment-type-btn {
  padding: 0.2rem 0.55rem;
  border: none;
  border-right: 1px solid var(--excel-border);
  background: #fff;
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--excel-muted);
  cursor: pointer;
}

.mode-btn:last-child,
.unit-btn:last-child,
.payment-type-btn:last-child {
  border-right: none;
}

.mode-btn.active,
.unit-btn.active,
.payment-type-btn.active {
  background: var(--excel-green);
  color: #fff;
}

.gst-fees {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (max-width: 900px) {
  .sections-grid {
    grid-template-columns: 1fr;
  }

  .gst-fees {
    grid-template-columns: 1fr;
  }
}

.hidden {
  display: none !important;
}

/* Landing records table */
.landing-records-wrap {
  overflow-x: auto;
}

.landing-records-table {
  min-width: 100%;
  white-space: nowrap;
  font-size: 9pt;
}

.landing-records-table .landing-group-row th {
  background: var(--excel-header);
  font-size: 8pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--excel-muted);
  text-align: center;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--excel-border-dark);
}

.landing-records-table .landing-col-row th {
  font-size: 8pt;
  white-space: nowrap;
}

.landing-records-table .landing-grp-products th,
.landing-records-table td.landing-grp-products {
  background: #fffef8;
}

.landing-records-table .landing-grp-invoice th,
.landing-records-table td.landing-grp-invoice {
  background: #f7fbff;
}

.landing-records-table .landing-grp-self th,
.landing-records-table td.landing-grp-self {
  background: #faf8ff;
}

.landing-records-table .landing-grp-gst th,
.landing-records-table td.landing-grp-gst {
  background: #fffaf5;
}

.landing-records-table .landing-grp-parcel th,
.landing-records-table td.landing-grp-parcel {
  background: #f8faf8;
}

.landing-records-table .landing-grp-custom th,
.landing-records-table td.landing-grp-custom {
  background: #fafafa;
}

.landing-records-table .landing-grp-landing th,
.landing-records-table td.landing-grp-landing {
  background: var(--excel-landing);
}

.landing-records-table th,
.landing-records-table td {
  font-size: 9pt;
  padding: 0.3rem 0.45rem;
}

.landing-records-table th {
  text-align: center !important;
}

.landing-records-table .col-landing-date {
  width: 1%;
  white-space: nowrap;
}

.landing-records-table td.col-landing-date {
  text-align: left !important;
}

.landing-records-table .col-landing-products {
  min-width: 12rem;
  max-width: 22rem;
}

.landing-records-table td.col-landing-products {
  text-align: left !important;
  white-space: normal;
  word-break: break-word;
}

.landing-records-table .col-landing-qty {
  width: 1%;
  white-space: nowrap;
}

.landing-records-table td.col-landing-qty {
  text-align: right !important;
}

.landing-records-table .col-landing-price,
.landing-records-table .col-landing-line-total {
  white-space: nowrap;
}

.landing-records-table td.col-landing-price,
.landing-records-table td.col-landing-line-total {
  text-align: right !important;
}

.landing-records-table tr.landing-product-extra-row td.landing-grp-products {
  border-top: 1px solid var(--excel-border);
}

.landing-records-table td[rowspan] {
  vertical-align: middle;
}

.landing-records-table .col-landing-rate {
  white-space: nowrap;
}

.landing-records-table .col-landing-inr,
.landing-records-table .col-landing-total {
  background: var(--excel-landing);
  font-weight: 700;
  color: var(--excel-green-dark);
  font-size: 10pt;
}

.landing-records-table .landing-grp-landing th {
  background: #e8f5e9;
  color: var(--excel-green-dark);
}

.landing-formula-note {
  margin: 0 0 0.65rem;
  padding: 0.45rem 0.65rem;
  background: var(--excel-landing);
  border: 1px solid var(--excel-green-dark);
  border-radius: 2px;
  font-size: 0.85rem;
}

.landing-records-table .col-landing-inr {
  background: var(--excel-landing);
  font-weight: 700;
  color: var(--excel-green-dark);
}

.landing-records-table tbody tr:hover td:not(.col-row-num) {
  background: var(--excel-select);
}

.landing-records-empty {
  margin: 0 0 0.5rem;
}

.landing-records-empty.hidden {
  display: none !important;
}

/* Seller sheet */
.seller-empty {
  margin: 0 0 0.5rem;
}

.seller-empty.hidden {
  display: none !important;
}

.seller-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.65rem;
  background: var(--excel-header);
  border: 1px solid var(--excel-border);
}

.seller-toolbar label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--excel-muted);
}

.seller-toolbar input[type="number"] {
  width: 5.5rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--excel-border-dark);
  background: #fff;
  text-align: right;
}

.seller-markup-btn {
  flex-direction: row !important;
  min-width: auto !important;
  font-size: 0.75rem !important;
  padding: 0.35rem 0.75rem !important;
}

.seller-table-wrap {
  overflow-x: auto;
  margin-bottom: 0.75rem;
}

.seller-table {
  table-layout: auto;
}

.seller-table .seller-group-row th {
  background: var(--excel-header);
  font-size: 8pt;
  font-weight: 700;
  text-align: center;
  padding: 0.25rem 0.4rem;
  border-bottom: 1px solid var(--excel-border-dark);
}

.seller-table .seller-col-row th {
  font-size: 9pt;
  white-space: nowrap;
}

.seller-table .seller-grp-product th,
.seller-table td.seller-grp-product {
  background: #fffef8;
}

.seller-table .seller-grp-pricing th,
.seller-table td.seller-grp-pricing {
  background: #f7fbff;
}

.seller-table td,
.seller-table th {
  font-size: 9pt;
  padding: 0.3rem 0.45rem;
}

.seller-table th {
  text-align: center !important;
}

.seller-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.seller-table .col-seller-date {
  width: 1%;
  min-width: 8.5rem;
  white-space: nowrap;
}

.seller-table td.col-seller-date {
  text-align: left !important;
}

.seller-table .col-seller-name {
  min-width: 14rem;
  max-width: 24rem;
}

.seller-table td.col-seller-name {
  text-align: left !important;
  white-space: normal;
  word-break: break-word;
}

.seller-table .col-seller-qty,
.seller-table .col-seller-num {
  white-space: nowrap;
}

.seller-table td.col-seller-qty,
.seller-table td.col-seller-num {
  text-align: right !important;
}

.seller-table .cell-input {
  padding: 0 !important;
}

.seller-table .selling-rate-input {
  min-width: 5rem;
}

.seller-table tr.seller-product-row td {
  vertical-align: middle;
}

.seller-table tr.seller-row-loss td {
  background: #fce4e4;
}

.seller-table tr.seller-row-loss .profit-cell {
  color: #c00000;
  font-weight: 600;
}

.seller-table tr.seller-bill-summary td {
  border-top: 1px solid var(--excel-border-dark);
}

.seller-table .seller-summary-label {
  text-align: right !important;
  font-weight: 600;
  color: var(--excel-muted);
  background: var(--excel-total) !important;
}

.seller-table .seller-summary-value {
  text-align: right !important;
  font-weight: 600;
  background: var(--excel-total) !important;
}

.seller-table .seller-summary-value .summary-loss {
  color: #c00000;
}

.row-seller-summary td {
  background: var(--excel-total);
  font-weight: 600;
}

.row-seller-margin td {
  background: var(--excel-landing) !important;
  font-weight: 700;
  border-top: 2px solid var(--excel-green-dark) !important;
  border-bottom: 2px solid var(--excel-green-dark) !important;
}

.row-seller-margin .seller-summary-label,
.row-seller-margin .seller-summary-value {
  background: var(--excel-landing) !important;
}

.row-seller-margin .seller-summary-value strong {
  color: var(--excel-green-dark);
  font-size: 1.05rem;
}

.row-seller-margin .seller-summary-value strong.summary-loss {
  color: #c00000;
}

.seller-table tr.seller-bill-start td {
  border-top: 2px solid var(--excel-border-dark);
}

.seller-date-cell {
  vertical-align: top;
}

.seller-bill-date {
  white-space: nowrap;
  margin-bottom: 0.25rem;
}

.seller-table .col-action {
  min-width: 6.5rem;
  width: 6.5rem;
  padding: 0.35rem 0.4rem !important;
  vertical-align: middle;
  background: #f3f3f3 !important;
  overflow: visible;
  position: sticky;
  right: 0;
  z-index: 5;
  box-shadow: -3px 0 6px rgba(0, 0, 0, 0.08);
}

.seller-table th.col-action {
  background: var(--excel-header) !important;
  font-size: 8pt;
  position: sticky;
  right: 0;
  z-index: 7;
  box-shadow: -3px 0 6px rgba(0, 0, 0, 0.1);
}

.seller-table td.col-action.is-action-open {
  z-index: 60;
}

.seller-table .seller-bill-summary .col-action {
  background: inherit !important;
  box-shadow: none;
}

.seller-gst-badge {
  display: inline-block;
  margin-bottom: 0.35rem;
  padding: 0.12rem 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.01em;
  color: #1a5276;
  background: #d6eaf8;
  border: 1px solid #85c1e9;
  border-radius: 2px;
}

.seller-gst-note {
  margin-bottom: 0.5rem;
}

.seller-gst-note strong {
  color: var(--excel-green-dark);
}

.btn-print-bill {
  display: block;
  width: 100%;
  padding: 0.2rem 0.35rem;
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid var(--excel-border-dark);
  border-radius: 2px;
  background: #fff;
  color: var(--excel-green-dark);
  cursor: pointer;
}

.btn-print-bill:hover {
  background: var(--excel-landing);
}

.btn-recalc,
.btn-duplicate {
  display: block;
  width: 100%;
  margin-top: 0.2rem;
  padding: 0.2rem 0.35rem;
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid var(--excel-border-dark);
  border-radius: 2px;
  background: #fff;
  color: var(--excel-text);
  cursor: pointer;
}

.btn-recalc:hover {
  background: #f0f7ff;
}

.btn-duplicate {
  color: var(--excel-green-dark);
}

.btn-duplicate:hover {
  background: #e8f5e9;
}

.btn-print-bill {
  white-space: nowrap;
}

/* Landing records — action buttons */
.landing-records-table .col-action {
  min-width: 6.5rem;
  width: 6.5rem;
  padding: 0.35rem 0.4rem !important;
  vertical-align: middle;
  background: #f3f3f3 !important;
  overflow: visible;
  position: sticky;
  right: 0;
  z-index: 5;
  box-shadow: -3px 0 6px rgba(0, 0, 0, 0.08);
}

.landing-records-table th.col-action {
  background: var(--excel-header) !important;
  font-size: 8pt;
  position: sticky;
  right: 0;
  z-index: 7;
  box-shadow: -3px 0 6px rgba(0, 0, 0, 0.1);
}

/* Open row stays above neighboring sticky Action cells */
.landing-records-table td.col-action.is-action-open {
  z-index: 60;
}

.landing-action-cell {
  text-align: center !important;
  position: relative;
  overflow: visible;
}

.landing-action-menu {
  position: relative;
  display: inline-block;
  width: 100%;
  z-index: 1;
}

.landing-action-menu.is-open {
  z-index: 40;
}

.landing-action-trigger {
  background: linear-gradient(180deg, #fff 0%, #e8e8e8 100%);
  color: #222;
  border-color: var(--excel-border-dark);
}

.landing-action-trigger:hover {
  background: linear-gradient(180deg, #f5f5f5 0%, #ddd 100%);
}

.landing-action-trigger:active {
  background: #ddd;
  box-shadow: none;
}

.landing-action-menu.is-open .landing-action-trigger {
  background: linear-gradient(180deg, #e8e8e8 0%, #d0d0d0 100%);
}

/* Panel is portaled to body while open — keep above sticky columns */
.landing-action-panel {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  min-width: 8.5rem;
  width: max-content;
  padding: 0.25rem;
  background: #fff;
  border: 1px solid var(--excel-border-dark);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  z-index: 10050;
}

.landing-action-panel.is-open {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem;
}

.landing-action-stack {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(2, auto);
  gap: 0.3rem;
  align-items: stretch;
  justify-items: stretch;
}

.landing-action-btn {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 1.55rem;
  padding: 0.28rem 0.35rem;
  font-family: var(--font);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  border-radius: 2px;
  border: 1px solid var(--excel-border-dark);
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.65) inset;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.landing-action-btn-recalculate {
  background: linear-gradient(180deg, #e8f5e9 0%, #c8e6c9 100%);
  color: var(--excel-green-dark);
  border-color: #81c784;
}

.landing-action-btn-recalculate:hover {
  background: linear-gradient(180deg, #c8e6c9 0%, #a5d6a7 100%);
  border-color: var(--excel-green-dark);
}

.landing-action-btn-recalculate:active {
  background: #a5d6a7;
  box-shadow: none;
}

.landing-action-btn-duplicate {
  background: linear-gradient(180deg, #e3f2fd 0%, #bbdefb 100%);
  color: #0d47a1;
  border-color: #64b5f6;
}

.landing-action-btn-duplicate:hover {
  background: linear-gradient(180deg, #bbdefb 0%, #90caf9 100%);
  border-color: #1976d2;
}

.landing-action-btn-duplicate:active {
  background: #90caf9;
  box-shadow: none;
}

.landing-action-btn-remove {
  background: linear-gradient(180deg, #fff 0%, #f5f5f5 100%);
  color: #a00000;
  border-color: #e0b4b4;
}

.landing-action-btn-remove:hover {
  background: linear-gradient(180deg, #fce4e4 0%, #f8cccc 100%);
  border-color: #c00000;
  color: #800000;
}

.landing-action-btn-remove:active {
  background: #f8cccc;
  box-shadow: none;
}

.landing-action-btn-view {
  background: linear-gradient(180deg, #e3f2fd 0%, #bbdefb 100%);
  color: #1565c0;
  border-color: #64b5f6;
}

.landing-action-btn-view:hover {
  background: linear-gradient(180deg, #bbdefb 0%, #90caf9 100%);
  border-color: #1565c0;
}

.landing-action-btn-view:active {
  background: #90caf9;
  box-shadow: none;
}

.landing-action-btn-dates {
  background: linear-gradient(180deg, #fff8e1 0%, #ffecb3 100%);
  color: #8d6e00;
  border-color: #f0c36d;
}

.landing-action-btn-dates:hover {
  background: linear-gradient(180deg, #ffecb3 0%, #ffe082 100%);
  border-color: #c9a227;
}

.landing-action-btn-dates:active {
  background: #ffe082;
  box-shadow: none;
}

.landing-action-btn-docs {
  background: linear-gradient(180deg, #f3e5f5 0%, #e1bee7 100%);
  color: #6a1b9a;
  border-color: #ce93d8;
}

.landing-action-btn-docs:hover {
  background: linear-gradient(180deg, #e1bee7 0%, #ce93d8 100%);
  border-color: #8e24aa;
}

.landing-action-btn-docs:active {
  background: #ce93d8;
  box-shadow: none;
}

.landing-action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.col-landing-arrival {
  white-space: nowrap;
  min-width: 7.5rem;
}

.col-landing-arrival.is-arrival-soon {
  background: #fff8e1;
  color: #8d6e00;
  font-weight: 600;
}

.col-landing-arrival.is-arrival-today {
  background: #ffebee;
  color: #b71c1c;
  font-weight: 700;
}

.date-input {
  width: 100%;
  max-width: 12rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid #b0b0b0;
  border-radius: 2px;
  font: inherit;
  background: #fff;
}

.arrival-alerts-bar {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid #f0c36d;
  background: linear-gradient(180deg, #fffbeb 0%, #fff3cd 100%);
  color: #5c4813;
}

.arrival-alerts-bar.hidden {
  display: none;
}

.arrival-alerts-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
  margin-bottom: 0.35rem;
}

.arrival-alerts-sub {
  font-size: 0.82rem;
  opacity: 0.85;
}

.arrival-alerts-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.arrival-alert-link {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0.15rem 0;
  text-align: left;
  font: inherit;
  color: #5c4813;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.arrival-alert-link:hover {
  color: #3e310c;
}

.arrival-alert-item.is-today .arrival-alert-link {
  color: #b71c1c;
  font-weight: 600;
}

.bill-docs-upload {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.bill-docs-upload.hidden {
  display: none;
}

.bill-docs-file-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.bill-docs-note {
  flex: 1 1 12rem;
  min-width: 10rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid #b0b0b0;
  border-radius: 2px;
  font: inherit;
}

.bill-docs-wrap {
  overflow: auto;
  max-height: min(50vh, 22rem);
}

.bill-docs-table {
  width: 100%;
}

.bill-docs-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.sheet-note.is-error {
  color: #b71c1c;
}

.seller-table td[rowspan] {
  vertical-align: middle;
}

/* Excel-style confirm dialog */
body.dialog-open {
  overflow: hidden;
}

.excel-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.4);
}

.excel-dialog-overlay.hidden {
  display: none !important;
}

.excel-dialog {
  width: min(100%, 30rem);
  background: #fff;
  border: 1px solid var(--excel-border-dark);
  box-shadow: 0 10px 38px rgba(0, 0, 0, 0.28);
  font-family: var(--font);
}

.excel-dialog-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  background: var(--excel-green);
  color: #fff;
}

.excel-dialog-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.excel-dialog-app-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  background: #fff;
  color: var(--excel-green);
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 2px;
  flex-shrink: 0;
}

.excel-dialog-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.excel-dialog-close {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 2px;
  background: transparent;
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.excel-dialog-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

.excel-dialog-body {
  padding: 1rem 1.1rem 0.85rem;
  background: #f9f9f9;
  border-bottom: 1px solid var(--excel-border);
}

.excel-dialog-content {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.excel-dialog-icon {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff3cd;
  border: 2px solid #ffc107;
  color: #856404;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.excel-dialog-message {
  flex: 1;
  min-width: 0;
}

.excel-dialog-heading {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--excel-text);
}

.excel-dialog-details {
  margin: 0 0 0.65rem;
  width: 100%;
}

.excel-dialog-details .cell-label {
  width: 38%;
  font-size: 0.82rem;
}

.excel-dialog-details .cell-value {
  font-size: 0.82rem;
}

.excel-dialog-note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--excel-muted);
  line-height: 1.45;
}

.excel-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #f3f3f3;
  border-top: 1px solid var(--excel-border);
}

.excel-dialog-btn {
  min-width: 5.5rem;
  padding: 0.35rem 0.85rem;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid var(--excel-border-dark);
  border-radius: 2px;
  background: linear-gradient(180deg, #fff 0%, #ececec 100%);
  color: var(--excel-text);
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.excel-dialog-btn:hover {
  background: linear-gradient(180deg, #f5f5f5 0%, #e2e2e2 100%);
  border-color: #999;
}

.excel-dialog-btn:active {
  background: #e2e2e2;
  box-shadow: none;
}

.excel-dialog-btn-danger {
  background: linear-gradient(180deg, #e53935 0%, #c62828 100%);
  border-color: #b71c1c;
  color: #fff;
}

.excel-dialog-btn-danger:hover {
  background: linear-gradient(180deg, #ef5350 0%, #d32f2f 100%);
  border-color: #a31515;
  color: #fff;
}

.excel-dialog-btn-cancel:focus,
.excel-dialog-btn-danger:focus,
.excel-dialog-close:focus {
  outline: 2px solid var(--excel-green);
  outline-offset: 1px;
}

/* Summary sheet */
.summary-empty.hidden,
.summary-layout.hidden {
  display: none !important;
}

.summary-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.summary-overall-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.85rem;
}

.summary-block {
  border: 1px solid var(--excel-border);
  background: #fff;
}

.summary-block-label {
  padding: 0.35rem 0.55rem;
  background: var(--excel-header);
  border-bottom: 1px solid var(--excel-border-dark);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--excel-header-text);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.summary-kv-table {
  width: 100%;
}

.summary-kv-table .cell-label {
  width: 58%;
  font-size: 0.85rem;
}

.summary-kv-table .cell-value {
  text-align: right !important;
  font-size: 0.85rem;
}

.summary-kv-table .row-summary-highlight {
  background: var(--excel-total);
}

.summary-kv-table .row-summary-margin {
  background: var(--excel-landing);
}

.summary-kv-table .row-summary-margin .cell-value strong {
  color: var(--excel-green-dark);
  font-size: 1rem;
}

.summary-kv-table .summary-loss {
  color: #c00000;
}

.summary-by-bill-section .section-label {
  margin-bottom: 0.5rem;
}

.summary-bills-table {
  font-size: 9pt;
}

.summary-bills-table th {
  text-align: center !important;
}

.summary-bills-table .col-summary-date {
  white-space: nowrap;
}

.summary-bills-table td.col-summary-date {
  text-align: left !important;
}

.summary-bills-table td.col-summary-num {
  text-align: right !important;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.summary-bills-table tr.summary-bill-loss td {
  background: #fff5f5;
}

.summary-bills-table .summary-loss {
  color: #c00000;
  font-weight: 600;
}

.summary-bills-table tfoot .row-summary-total td {
  background: var(--excel-landing);
  font-weight: 700;
  border-top: 2px solid var(--excel-green-dark);
}

.summary-bills-table .summary-foot-label {
  text-align: left !important;
  font-weight: 700;
  color: var(--excel-green-dark);
}

/* Workbook footer — generate bar + Excel sheet tabs */
.excel-workbook-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: #e8e8e8;
  border-top: 1px solid var(--excel-border-dark);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

.landing-sticky-bar {
  background: #fff;
  border-bottom: 1px solid var(--excel-border);
}

.landing-sticky-bar.hidden {
  display: none;
}

.landing-sticky-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
}

.sheet-mobile-nav {
  display: none;
}

.excel-sheet-tabs {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.15rem 0.5rem 0;
  min-height: 2.1rem;
}

.sheet-tab {
  padding: 0.35rem 1rem 0.4rem;
  border: 1px solid var(--excel-border-dark);
  border-bottom: none;
  border-radius: 5px 5px 0 0;
  background: #d6dce4;
  font-family: var(--font);
  font-size: 0.8rem;
  color: var(--excel-text);
  cursor: pointer;
  margin-right: 3px;
  position: relative;
  top: 1px;
}

.sheet-tab.active {
  background: #fff;
  font-weight: 600;
  color: var(--excel-green-dark);
  top: 0;
  padding-bottom: 0.5rem;
  z-index: 1;
}

.sheet-tab:hover:not(.active) {
  background: #ececec;
}

.sheet-tab:focus-visible {
  outline: 2px solid var(--excel-green);
  outline-offset: 1px;
}

.landing-sticky-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--excel-muted);
  flex: 1;
  min-width: 12rem;
}

.landing-sticky-hint.is-ready {
  color: var(--excel-green-dark);
  font-weight: 600;
}

.landing-sticky-hint.is-success {
  color: var(--excel-green-dark);
  font-weight: 600;
}

.landing-sticky-hint.is-error {
  color: #c00000;
  font-weight: 600;
}

.landing-generate-btn {
  padding: 0.55rem 1.25rem;
  border: none;
  border-radius: 2px;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--excel-green);
  color: #fff;
  white-space: nowrap;
}

.landing-generate-btn:hover:not(:disabled) {
  background: var(--excel-green-dark);
}

.landing-generate-btn:disabled {
  background: #bdbdbd;
  color: #fff;
  cursor: not-allowed;
}

@media print {
  @page {
    margin: 10mm;
    size: A4;
  }

  body {
    background: #fff;
    padding-bottom: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .excel-app {
    border: 1px solid var(--excel-border-dark);
    box-shadow: none;
    max-width: none;
    min-height: auto;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .no-print {
    display: none !important;
  }

  .calc-product-suggestions {
    display: none !important;
  }

  #productTable tbody tr.is-blank-row {
    display: none !important;
  }

  /* Title bar — same as screen */
  .excel-titlebar {
    background: var(--excel-green) !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .workbook-name,
  .workbook-sub,
  .titlebar-rate label,
  .titlebar-rate span {
    color: #fff !important;
  }

  .titlebar-rate input {
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    background: rgba(0, 0, 0, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.45) !important;
  }

  .excel-icon {
    background: #fff !important;
    color: var(--excel-green) !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Same grid layout as screen */
  .sections-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem;
  }

  .sections-grid .sheet-section-wide {
    grid-column: 1 / -1;
  }

  .gst-fees {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 0.5rem;
  }

  .excel-sheet {
    padding: 0.5rem;
    overflow: visible;
  }

  .sheet-section,
  .sheet-section-full,
  .grid-wrap {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Preserve table styling */
  .calc-table th,
  .calc-table td.col-row-num,
  .sheet-kv .cell-label,
  .calc-table tfoot td,
  .row-highlight td,
  .row-total-line td {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .row-landing-total td {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border: 2px solid var(--excel-green-dark) !important;
    font-size: 1.15rem !important;
    padding: 0.85rem 1rem !important;
  }

  .landing-records-table .col-landing-inr {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .row-landing-total .cell-value strong {
    font-size: 1.5rem !important;
  }

  .calc-table tbody tr:hover td:not(.col-row-num) {
    background: var(--excel-cell) !important;
  }

  .mode-btn.active,
  .unit-btn.active,
  .payment-type-btn.active {
    background: var(--excel-green) !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  input[type="text"],
  input[type="number"] {
    border: none !important;
    outline: none !important;
    background: transparent !important;
    color: var(--excel-text) !important;
    -webkit-text-fill-color: var(--excel-text) !important;
  }

  .titlebar-rate input[type="number"] {
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    background: rgba(0, 0, 0, 0.2) !important;
  }

  .hidden {
    display: none !important;
  }

  .workbook-pane.hidden {
    display: none !important;
  }

  body.print-sheet-calculator #sheetLanding,
  body.print-sheet-calculator #sheetSeller,
  body.print-sheet-calculator #sheetSummary,
  body.print-sheet-landing #sheetCalculator,
  body.print-sheet-landing #sheetSeller,
  body.print-sheet-landing #sheetSummary,
  body.print-sheet-seller #sheetCalculator,
  body.print-sheet-seller #sheetLanding,
  body.print-sheet-seller #sheetSummary,
  body.print-sheet-summary #sheetCalculator,
  body.print-sheet-summary #sheetLanding,
  body.print-sheet-summary #sheetSeller {
    display: none !important;
  }

  body.print-sheet-calculator #sheetCalculator,
  body.print-sheet-landing #sheetLanding,
  body.print-sheet-seller #sheetSeller,
  body.print-sheet-summary #sheetSummary {
    display: block !important;
  }

  /* Landing records — wide table: no crop, landscape-friendly */
  body.print-sheet-landing .excel-app,
  body.print-sheet-landing .workbook-panes,
  body.print-sheet-landing .excel-sheet,
  body.print-sheet-landing .sheet-section-full,
  body.print-sheet-landing .landing-records-wrap,
  body.print-sheet-landing .grid-wrap-full {
    overflow: visible !important;
    max-width: none !important;
    width: 100% !important;
  }

  body.print-sheet-landing .sheet-section-full,
  body.print-sheet-landing .landing-records-wrap {
    break-inside: auto;
    page-break-inside: auto;
  }

  body.print-sheet-landing .landing-records-table {
    width: max-content;
    min-width: 100%;
    font-size: 7pt;
    table-layout: auto;
  }

  body.print-sheet-landing .landing-records-table thead {
    display: table-header-group;
  }

  body.print-sheet-landing .landing-records-table .landing-group-row th,
  body.print-sheet-landing .landing-records-table .landing-col-row th,
  body.print-sheet-landing .landing-records-table td {
    padding: 0.12rem 0.28rem;
    font-size: 7pt;
    white-space: nowrap;
  }

  body.print-sheet-landing .landing-records-table .col-landing-products {
    min-width: 7rem;
    max-width: 12rem;
    white-space: normal;
    word-break: break-word;
  }

  body.print-sheet-landing .landing-records-table tbody tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Seller — wide table print */
  body.print-sheet-seller .seller-table-wrap,
  body.print-sheet-seller .excel-sheet {
    overflow: visible !important;
  }

  body.print-sheet-seller .seller-table {
    font-size: 8pt;
  }

  body.print-sheet-seller .seller-table thead {
    display: table-header-group;
  }

  body.print-seller-single-bill .seller-bill-print-exclude {
    display: none !important;
  }

  body.print-seller-single-bill .seller-table tbody tr.seller-bill-print-include {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body.print-seller-single-bill .selling-rate-input {
    border: none !important;
    background: transparent !important;
    outline: none !important;
  }

  /* Summary — print */
  body.print-sheet-summary .excel-app,
  body.print-sheet-summary .workbook-panes,
  body.print-sheet-summary .excel-sheet,
  body.print-sheet-summary .sheet-section-full,
  body.print-sheet-summary .summary-layout,
  body.print-sheet-summary .grid-wrap-full {
    overflow: visible !important;
    max-width: none !important;
    width: 100% !important;
  }

  body.print-sheet-summary .summary-overall-wrap {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.print-sheet-summary .summary-bills-table thead {
    display: table-header-group;
  }

  body.print-sheet-summary .summary-bills-table tfoot {
    display: table-footer-group;
  }

  /* Calculator — long sheet: allow page breaks, no crop */
  body.print-sheet-calculator .excel-app,
  body.print-sheet-calculator .workbook-panes,
  body.print-sheet-calculator .excel-sheet,
  body.print-sheet-calculator .grid-wrap,
  body.print-sheet-calculator .grid-wrap-full {
    overflow: visible !important;
    max-width: none !important;
    width: 100% !important;
  }

  body.print-sheet-calculator .sheet-section-full {
    break-inside: auto;
    page-break-inside: auto;
    margin-bottom: 0.35rem;
  }

  body.print-sheet-calculator .sheet-kv,
  body.print-sheet-calculator .landing-total-section .landing-breakdown {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body.print-sheet-calculator #productTable thead {
    display: table-header-group;
  }

  body.print-sheet-calculator #productTable tbody tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body.print-sheet-calculator #productTable tbody tr.is-blank-row {
    display: none !important;
  }

  body.print-sheet-calculator .gst-fees {
    break-inside: auto;
    page-break-inside: auto;
  }

  body.print-sheet-calculator .sheet-section.nested {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body.print-sheet-calculator .calc-table {
    font-size: 9pt;
  }

  body.print-sheet-calculator .sheet-kv .cell-label {
    width: 52%;
  }

  body.print-sheet-calculator input[type="number"],
  body.print-sheet-calculator input[type="text"] {
    font-size: 9pt;
  }

  body.print-sheet-calculator .calc-product-suggestions {
    display: none !important;
  }
}

/* Mobile rules consolidated at end of file */

/* Auth titlebar */
.titlebar-auth {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-left: auto;
  font-size: 0.8125rem;
}

.titlebar-user {
  color: #fff;
}

.titlebar-home-link {
  color: #fff;
  font-size: 0.8125rem;
  text-decoration: none;
  margin-right: 0.35rem;
  opacity: 0.95;
}

.titlebar-home-link:hover {
  text-decoration: underline;
  opacity: 1;
}

.titlebar-logout-btn,
.titlebar-admin-select {
  font: inherit;
  border: 1px solid var(--excel-border, #c8c8c8);
  background: #fff;
  padding: 0.25rem 0.5rem;
  border-radius: 2px;
  cursor: pointer;
}

.titlebar-admin-label {
  font-size: 0.75rem;
  color: #fff;
}

.excel-titlebar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Loading overlay */
.app-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.72);
}

.app-loading-overlay.hidden {
  display: none;
}

.app-loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--excel-border, #c8c8c8);
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  min-width: 12rem;
}

.app-loading-spinner {
  width: 1.75rem;
  height: 1.75rem;
  border: 3px solid #e0e0e0;
  border-top-color: var(--excel-accent, #217346);
  border-radius: 50%;
  animation: app-spin 0.8s linear infinite;
}

@keyframes app-spin {
  to {
    transform: rotate(360deg);
  }
}

.app-loading-message {
  margin: 0;
  font-size: 0.875rem;
  color: #333;
}

body.app-read-only .landing-sticky-bar,
body.app-read-only #generateLandingBtn {
  opacity: 0.55;
  pointer-events: none;
}

.login-home-link {
  margin-left: auto;
  color: #fff;
  font-size: 0.8125rem;
  text-decoration: none;
  opacity: 0.95;
}

.login-home-link:hover {
  text-decoration: underline;
  opacity: 1;
}

.login-page {
  min-height: 100vh;
  background: var(--excel-bg, #f3f3f3);
}

.login-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.login-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  width: min(100%, 22rem);
  border: 1px solid var(--excel-border, #c8c8c8);
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.login-tabs {
  display: flex;
  border-bottom: 1px solid var(--excel-border, #c8c8c8);
}

.login-tab {
  flex: 1;
  border: 0;
  background: #f9f9f9;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font: inherit;
}

.login-tab.active {
  background: #fff;
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--excel-accent, #217346);
}

.login-form {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.login-field label {
  display: block;
  font-size: 0.8125rem;
  margin-bottom: 0.25rem;
}

.login-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--excel-border, #c8c8c8);
  font: inherit;
}

.login-submit {
  margin-top: 0.25rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--excel-accent, #217346);
  background: var(--excel-accent, #217346);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.login-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-error {
  margin: 0;
  font-size: 0.8125rem;
  color: #b00020;
}

/* Calculator product extras */
#productTable .col-seller-name,
#productTable .col-product-url {
  min-width: 8rem;
}

#productTable .product-seller-name,
#productTable .product-url,
#productTable .product-name {
  width: 100%;
  min-width: 7rem;
}

.calc-product-suggestions {
  position: fixed;
  left: 0;
  top: 0;
  right: auto;
  z-index: 80;
  min-width: 16rem;
  max-width: min(36rem, calc(100vw - 1rem));
}

.excel-dialog-wide {
  max-width: 36rem;
  width: min(96vw, 36rem);
}

.price-history-wrap {
  overflow-x: auto;
  max-height: 18rem;
  overflow-y: auto;
}

.price-history-table td,
.price-history-table th {
  font-size: 0.8125rem;
}

/* Price List sheet */
.price-list-meta { font-size: 0.8125rem; color: var(--excel-muted, #5a5a5a); }
.price-list-note { margin-bottom: 0.65rem; }
.price-list-wrap { overflow-x: auto; margin-bottom: 0.75rem; max-width: 100%; }
.price-list-table { table-layout: auto; width: 100%; }
.price-list-table th, .price-list-table td { font-size: 9pt; padding: 0.35rem 0.5rem; vertical-align: middle; }
.price-list-table th { text-align: center !important; white-space: nowrap; }
.price-list-table .col-pl-product { min-width: 12rem; }
.price-list-table td.col-pl-product { text-align: left !important; }
.price-list-product-label { white-space: normal; word-break: break-word; line-height: 1.35; }
.price-list-table .col-pl-current,
.price-list-table .col-pl-previous { width: 6.5rem; min-width: 6.5rem; white-space: nowrap; }
.price-list-table td.col-pl-current,
.price-list-table td.col-pl-previous { text-align: right !important; }
.price-list-table .col-pl-change { width: 7rem; min-width: 7rem; white-space: nowrap; }
.price-list-table td.col-pl-change { text-align: right !important; }
.price-list-table .col-pl-bill { width: 9rem; min-width: 9rem; }
.price-list-table td.col-pl-bill { text-align: left !important; }
.price-list-table .col-pl-history { width: 6.5rem; min-width: 6.5rem; white-space: nowrap; }
.price-list-table td.col-pl-history { text-align: center !important; }
.price-list-usd { font-variant-numeric: tabular-nums; }
.price-list-change-up { color: #107c41; }
.price-list-change-down { color: #c0392b; }
.price-list-bill-cell { display: flex; flex-direction: column; gap: 0.2rem; align-items: flex-start; }
.price-list-bill-date { font-size: 0.8125rem; color: var(--excel-muted, #5a5a5a); white-space: nowrap; }
.price-list-bill-link,
.price-list-history-btn {
  font: inherit;
  font-size: 0.8125rem;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--excel-border, #b4b4b4);
  border-radius: 2px;
  background: var(--excel-cell-bg, #fff);
  cursor: pointer;
  color: var(--excel-link, #0563c1);
}
.price-list-bill-link:hover,
.price-list-history-btn:hover { background: var(--excel-hover, #e7e7e7); }
.excel-dialog-wide { max-width: 52rem; width: min(96vw, 52rem); }
.price-list-history-product { font-weight: 600; margin: 0 0 0.35rem; }
.price-list-history-current { margin: 0 0 0.75rem; color: var(--excel-muted, #5a5a5a); font-size: 0.875rem; }
.price-list-history-wrap { overflow-x: auto; max-height: 24rem; }
.price-list-history-table { width: 100%; table-layout: auto; }
.price-list-history-table th,
.price-list-history-table td { font-size: 9pt; padding: 0.35rem 0.5rem; vertical-align: middle; }
.price-list-history-table th { text-align: center !important; white-space: nowrap; }
.price-list-history-table td:nth-child(2),
.price-list-history-table td:nth-child(3),
.price-list-history-table td:nth-child(4),
.price-list-history-table td:nth-child(5) { text-align: right !important; }
.price-list-history-empty { margin-top: 0.5rem; }
body.sheet-pricelist .landing-sticky-bar { display: none; }
body.sheet-brands .landing-sticky-bar { display: none; }

.brand-manage-grid {
  display: grid;
  grid-template-columns: minmax(16rem, 0.9fr) minmax(20rem, 1.2fr);
  gap: 1rem;
  align-items: start;
}

.brand-rename-input,
.brand-assign-select {
  width: 100%;
  min-width: 8rem;
}

#productTable .col-brand-name,
#productTable .product-brand {
  min-width: 7rem;
}

#productTable .product-brand {
  width: 100%;
}

.calc-product-hint {
  margin: 0.4rem 0 0;
}

.calc-product-hint.error {
  color: #b71c1c;
  font-style: normal;
  font-weight: 600;
}

#productTable tbody tr.calc-row-dup {
  outline: 2px solid #c62828;
  outline-offset: -2px;
  background: #fdecea;
}

.col-seller-brand,
.col-landing-brand,
.col-pl-brand {
  min-width: 6.5rem;
}

@media (max-width: 900px) {
  .brand-manage-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Mobile responsive (desktop unchanged above breakpoints) ===== */

.tab-label-short {
  display: none;
}

@media (max-width: 900px) {
  /* Calculator sticky generate bar + sheet dropdown */
  body {
    padding-bottom: calc(9.25rem + env(safe-area-inset-bottom, 0px));
  }

  /* Other sheets: sheet dropdown only */
  body.sheet-landing,
  body.sheet-seller,
  body.sheet-lotsales,
  body.sheet-summary,
  body.sheet-pricelist,
  body.sheet-brands {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
  }

  html,
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .excel-app {
    width: 100%;
    max-width: none;
    min-width: 0;
    min-height: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
    overflow: visible;
  }

  .workbook-panes,
  .workbook-pane {
    width: 100%;
    min-width: 0;
    overflow: visible;
  }

  .excel-sheet {
    overflow-x: auto;
    overflow-y: visible;
  }

  /* Login page: keep compact header row, full-width centered card */
  .login-page .excel-titlebar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .login-page .titlebar-left {
    width: auto;
    flex: 1;
    min-width: 0;
  }

  .login-page .login-home-link {
    margin-left: auto;
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.75rem;
  }

  .login-app,
  .login-main {
    width: 100%;
  }

  .login-main {
    align-items: center;
    justify-content: center;
    padding: 1.25rem 1rem;
  }

  .login-card {
    width: 100%;
    max-width: 22rem;
    margin-inline: auto;
  }

  .excel-titlebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.45rem 0.5rem;
    padding: 0.45rem 0.6rem;
  }

  .titlebar-left {
    width: auto;
    min-width: 0;
    grid-column: 1;
  }

  .titlebar-left > div {
    min-width: 0;
  }

  .workbook-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .workbook-sub {
    display: none;
  }

  .titlebar-rate {
    grid-column: 2;
    width: auto;
    max-width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 0.25rem;
    padding: 0.25rem 0.4rem;
    white-space: nowrap;
  }

  .titlebar-rate label,
  .titlebar-rate span {
    white-space: nowrap;
    font-size: 0.7rem;
  }

  .titlebar-rate input {
    width: 4.5rem;
    min-width: 0;
  }

  .titlebar-auth {
    grid-column: 1 / -1;
    width: 100%;
    margin-left: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "home logout"
      "admin admin";
    gap: 0.4rem;
    align-items: center;
  }

  .titlebar-user {
    display: none;
  }

  .titlebar-admin-label {
    display: none;
  }

  .titlebar-home-link {
    grid-area: home;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    margin-right: 0;
    padding: 0.35rem 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.12);
    text-align: center;
  }

  .titlebar-logout-btn {
    grid-area: logout;
    min-height: 2.5rem;
    padding: 0.35rem 0.75rem;
    width: 100%;
  }

  .titlebar-admin-select:not(.hidden) {
    grid-area: admin;
    width: 100%;
    min-height: 2.5rem;
    font-size: 0.85rem;
  }

  .excel-ribbon {
    padding: 0.3rem 0.5rem;
  }

  .ribbon-group {
    width: 100%;
    justify-content: flex-start;
  }

  .ribbon-btn {
    min-height: 2.75rem;
    flex: 0 1 auto;
  }

  .excel-sheet {
    padding: 0.4rem;
    max-width: 100%;
  }

  .grid-wrap,
  .landing-records-wrap,
  .seller-table-wrap,
  .price-list-wrap,
  .price-history-wrap,
  .price-list-history-wrap {
    width: 100%;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .grid-wrap {
    position: relative;
  }

  .grid-wrap::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 1.25rem;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.07), transparent);
    pointer-events: none;
  }

  /* Prevent iOS zoom on focus */
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="password"],
  .login-field input,
  .titlebar-rate input,
  .seller-toolbar input[type="number"] {
    font-size: 16px;
  }

  .mode-switch,
  .weight-unit-switch,
  .payment-type-switch {
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
  }

  .mode-btn,
  .unit-btn,
  .payment-type-btn {
    flex: 1 1 auto;
    min-height: 2.5rem;
    padding: 0.4rem 0.65rem;
    font-size: 0.78rem;
  }

  .seller-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .seller-toolbar input[type="number"] {
    width: 100%;
    min-height: 2.75rem;
  }

  .seller-markup-btn {
    width: 100% !important;
    min-height: 2.75rem !important;
    justify-content: center;
  }

  .btn-remove {
    width: 2.25rem;
    height: 2.25rem;
    min-height: 2.25rem;
    font-size: 1rem;
  }

  .landing-sticky-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    padding: 0.45rem 0.65rem;
  }

  .landing-sticky-hint {
    min-width: 0;
    flex: none;
    font-size: 0.8rem;
    line-height: 1.3;
  }

  .landing-generate-btn {
    width: 100%;
    min-height: 2.6rem;
  }

  /* Wide spreadsheet tables: keep scroll inside the wrap */
  .grid-wrap-full,
  .landing-records-wrap,
  .seller-table-wrap,
  .price-list-wrap {
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .excel-workbook-footer {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Mobile: sheet picker dropdown (desktop tabs stay unchanged) */
  .sheet-mobile-nav {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.45rem 0.65rem;
    background: #fff;
    border-top: 1px solid var(--excel-border);
  }

  .sheet-mobile-label {
    flex-shrink: 0;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--excel-green-dark);
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  .sheet-mobile-select {
    flex: 1;
    min-width: 0;
    min-height: 2.75rem;
    padding: 0.45rem 2.25rem 0.45rem 0.75rem;
    border: 1px solid var(--excel-border-dark);
    border-radius: 2px;
    background-color: #fff;
    background-image: linear-gradient(45deg, transparent 50%, var(--excel-green-dark) 50%),
      linear-gradient(135deg, var(--excel-green-dark) 50%, transparent 50%);
    background-position: calc(100% - 1rem) calc(50% - 0.15rem), calc(100% - 0.65rem) calc(50% - 0.15rem);
    background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
    background-repeat: no-repeat;
    font-family: var(--font);
    font-size: 16px;
    font-weight: 600;
    color: var(--excel-text);
    appearance: none;
    -webkit-appearance: none;
  }

  .sheet-mobile-select:focus {
    outline: 2px solid var(--excel-green);
    outline-offset: 1px;
  }

  .excel-sheet-tabs {
    display: none;
  }

  .excel-dialog-overlay {
    padding: 0.65rem;
    align-items: flex-end;
  }

  .excel-dialog,
  .excel-dialog-wide {
    width: 100%;
    max-width: none;
    max-height: calc(100vh - 1.5rem - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
  }

  .excel-dialog-footer {
    flex-wrap: wrap;
  }

  .excel-dialog-btn {
    flex: 1 1 auto;
    min-height: 2.75rem;
  }

  .row-landing-total td {
    padding: 0.65rem 0.75rem;
    font-size: 1.05rem;
  }

  .row-landing-total .cell-label {
    font-size: 1.05rem;
  }

  .row-landing-total .cell-value strong {
    font-size: 1.25rem;
  }

  .summary-overall-wrap {
    grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr));
  }
}

@media (max-width: 640px) {
  .sheet-kv .cell-label {
    width: 55%;
    font-size: 9pt;
    white-space: normal;
    word-break: break-word;
    line-height: 1.25;
  }

  .calc-table {
    font-size: 10pt;
  }

  .calc-table th,
  .calc-table td {
    padding: 0.3rem 0.4rem;
  }

  .workbook-name {
    font-size: 0.8rem;
  }

  .workbook-sub {
    display: none;
  }

  .titlebar-rate input {
    width: 4.75rem;
    /* keep 16px to avoid iOS focus zoom */
    font-size: 16px;
  }

  .summary-overall-wrap {
    grid-template-columns: 1fr;
  }

  .section-head-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .excel-dialog-footer {
    flex-direction: column-reverse;
  }

  .excel-dialog-btn {
    width: 100%;
  }

  .landing-records-table .col-action,
  .seller-table .col-action {
    min-width: 5.75rem;
    width: 5.75rem;
  }

  .landing-action-panel {
    min-width: 7.75rem;
  }

  .landing-action-btn {
    font-size: 0.62rem;
    padding: 0.24rem 0.25rem;
  }
}

@media (max-width: 480px) {
  body {
    padding-bottom: calc(9.5rem + env(safe-area-inset-bottom, 0px));
  }

  body.sheet-landing,
  body.sheet-seller,
  body.sheet-lotsales,
  body.sheet-summary,
  body.sheet-pricelist,
  body.sheet-brands {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
  }

  .sheet-mobile-nav {
    padding: 0.4rem 0.5rem;
  }

  .excel-titlebar {
    grid-template-columns: 1fr;
    padding: 0.4rem 0.5rem;
  }

  .titlebar-rate {
    grid-column: 1;
    width: 100%;
    justify-content: center;
  }

  .workbook-sub {
    display: none;
  }

  .titlebar-auth {
    font-size: 0.75rem;
  }

  .titlebar-home-link {
    margin-right: 0;
  }

  .landing-sticky-hint {
    font-size: 0.78rem;
  }

  .ribbon-group {
    gap: 0.25rem;
  }

  .ribbon-btn {
    min-width: 3rem;
    font-size: 0.6rem;
  }

  .excel-sheet {
    padding: 0.3rem;
  }

  .summary-overall-wrap {
    grid-template-columns: 1fr;
  }

  .landing-sticky-inner {
    padding: 0.5rem;
  }

  .landing-generate-btn {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
  }

  .login-main {
    align-items: center;
    justify-content: center;
    padding: 1rem 0.75rem;
  }

  .login-card {
    max-width: none;
  }

  .login-page .workbook-sub {
    display: none;
  }

  .login-submit,
  .login-tab {
    min-height: 2.75rem;
  }
}

/* Final bill dialog */
.excel-dialog-final-bill {
  width: min(96vw, 42rem);
  max-width: 42rem;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.excel-dialog-final-bill .excel-dialog-body {
  overflow-y: auto;
  flex: 1;
  padding: 1rem 1.1rem;
}

.final-bill-content .final-bill-header {
  border-bottom: 2px solid var(--excel-green);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.final-bill-content .final-bill-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
  color: var(--excel-green-dark);
  font-family: var(--font);
}

.final-bill-content .final-bill-meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--excel-muted, #5a5a5a);
}

.final-bill-content .final-bill-section {
  margin-bottom: 1.1rem;
}

.final-bill-content .final-bill-section h2 {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--excel-muted, #5a5a5a);
  font-weight: 600;
}

.final-bill-content .final-bill-table,
.final-bill-content .final-bill-summary {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.final-bill-content .final-bill-table th,
.final-bill-content .final-bill-table td {
  border: 1px solid var(--excel-border);
  padding: 0.4rem 0.5rem;
  text-align: left;
  vertical-align: top;
}

.final-bill-content .final-bill-table th {
  background: var(--excel-header);
  font-weight: 600;
}

.final-bill-content .final-bill-table .num,
.final-bill-content .final-bill-summary .value {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.final-bill-content .final-bill-table .link {
  word-break: break-all;
  font-size: 0.75rem;
}

.final-bill-content .final-bill-summary td {
  padding: 0.32rem 0.5rem;
  border-bottom: 1px solid var(--excel-border);
}

.final-bill-content .final-bill-summary .label {
  color: var(--excel-muted, #5a5a5a);
}

.final-bill-content .final-bill-summary .section-row td {
  border-bottom: none;
  padding-top: 0.7rem;
  padding-bottom: 0.12rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--excel-green-dark);
}

.final-bill-content .final-bill-summary .highlight td {
  background: #f7faf8;
}

.final-bill-content .final-bill-summary .total td {
  border-top: 2px solid var(--excel-green);
  border-bottom: none;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--excel-green-dark);
  padding-top: 0.55rem;
}

.final-bill-content .final-bill-note {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  color: var(--excel-muted, #5a5a5a);
}

.final-bill-content .final-bill-per-piece {
  margin: 0.65rem 0 0;
  font-size: 0.875rem;
}

@media print {
  body.print-sheet-final-bill .excel-app,
  body.print-sheet-final-bill .excel-workbook-footer {
    display: none !important;
  }

  body.print-sheet-final-bill #finalBillOverlay {
    display: flex !important;
    position: static;
    inset: auto;
    background: none;
    padding: 0;
    z-index: auto;
  }

  body.print-sheet-final-bill #finalBillOverlay.hidden {
    display: flex !important;
  }

  body.print-sheet-final-bill .excel-dialog-titlebar,
  body.print-sheet-final-bill .excel-dialog-footer,
  body.print-sheet-final-bill .no-print {
    display: none !important;
  }

  body.print-sheet-final-bill .excel-dialog-final-bill {
    width: 100%;
    max-width: none;
    max-height: none;
    box-shadow: none;
    border: none;
  }

  body.print-sheet-final-bill .excel-dialog-body {
    overflow: visible;
    padding: 0;
  }
}

.order-kind-select {
  min-width: 10rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid #b0b0b0;
  border-radius: 2px;
  font: inherit;
  background: #fff;
}

.order-kind-note {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: #666;
}

.landing-grp-client-pay th,
.landing-grp-client-pay td {
  background: #faf8f4;
}

.order-kind-cell.order-kind-pre {
  color: #8a5a00;
  font-weight: 600;
}

.order-kind-cell.order-kind-bulk {
  color: #0d5c8a;
  font-weight: 600;
}

.payment-status-cell.payment-status-paid {
  color: #1b5e20;
  font-weight: 600;
}

.payment-status-cell.payment-status-partial {
  color: #e65100;
  font-weight: 600;
}

.payment-status-cell.payment-status-unpaid {
  color: #b71c1c;
  font-weight: 600;
}

.landing-action-btn-payments {
  border-color: #7b5a1a;
  color: #7b5a1a;
}

.landing-action-btn-payments:hover {
  background: #faf3e6;
}

.bill-payments-summary {
  margin-bottom: 0.85rem;
}

.bill-payments-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.bill-payments-summary-grid div {
  padding: 0.55rem 0.65rem;
  border: 1px solid #d8d8d8;
  background: #fafafa;
}

.bill-payments-summary-grid span {
  display: block;
  font-size: 0.75rem;
  color: #666;
  margin-bottom: 0.15rem;
}

.bill-payments-summary-grid strong {
  font-size: 0.95rem;
}

.bill-payments-pending {
  color: #b71c1c;
}

.bill-payments-form {
  margin-bottom: 0.85rem;
}

.bill-payments-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  align-items: end;
}

.bill-payments-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.bill-payments-form-grid input,
.bill-payments-form-grid select {
  padding: 0.3rem 0.45rem;
  border: 1px solid #b0b0b0;
  border-radius: 2px;
  font: inherit;
}

.bill-payments-note-field {
  grid-column: span 2;
}

.bill-payments-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.bill-payments-wrap {
  overflow: auto;
  max-height: min(50vh, 22rem);
}

.bill-payments-table {
  width: 100%;
}

.bill-payments-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.bill-payments-action-btn {
  border: 1px solid #b0b0b0;
  background: #fff;
  padding: 0.15rem 0.45rem;
  font: inherit;
  cursor: pointer;
}

.bill-payments-action-delete {
  color: #b71c1c;
  border-color: #d8a0a0;
}

.payment-status-paid {
  color: #1b5e20;
}

.payment-status-partial {
  color: #e65100;
}

.payment-status-unpaid {
  color: #b71c1c;
}

@media (max-width: 900px) {
  .bill-payments-summary-grid,
  .bill-payments-form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .bill-payments-note-field {
    grid-column: span 2;
  }
}

/* Lot Sales sheet — match Seller / Landing spacing */
.lot-sales-kpis {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--excel-muted);
}

.lot-kpi strong {
  margin-left: 0.25rem;
  color: var(--excel-green-dark);
  font-variant-numeric: tabular-nums;
}

.lot-kpi-profit strong.is-loss {
  color: #b71c1c;
}

#sheetLotSales .section-head-row .section-label {
  margin-bottom: 0;
}

.lot-sale-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 36rem;
}

.lot-sale-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 0.65rem;
  align-items: end;
}

.lot-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--excel-muted);
  min-width: 0;
}

.lot-field-label-spacer {
  visibility: hidden;
  line-height: 1.2;
}

.lot-field-submit {
  margin-top: 0.45rem;
}

.lot-field-submit .ribbon-btn {
  width: 100%;
  min-height: 1.9rem;
  justify-content: center;
}

.lot-sale-form input,
.lot-sale-form select {
  display: block;
  font: inherit;
  font-weight: 500;
  color: var(--excel-text);
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--excel-border-dark);
  background: #fff;
  width: 100%;
  min-height: 1.9rem;
  box-sizing: border-box;
}

.lot-sale-hint {
  margin: 0.15rem 0 0;
  min-height: 0;
}

.lot-sale-hint:empty {
  display: none;
}

.lot-sale-hint.ok {
  color: #1b5e20;
  font-style: normal;
  font-weight: 600;
}

.lot-sale-hint.error {
  color: #b71c1c;
  font-style: normal;
  font-weight: 600;
}

.lot-yt-search {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.lot-yt-search-wrap {
  position: relative;
}

.lot-yt-search-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--excel-border-dark);
  background: #fff;
  padding: 0.1rem 0.35rem 0.1rem 0.45rem;
  min-height: 1.9rem;
}

.lot-yt-search-bar:focus-within {
  outline: 2px solid var(--excel-green);
  outline-offset: 0;
  border-color: var(--excel-green-dark);
}

.lot-yt-icon {
  width: 0.8rem;
  height: 0.8rem;
  flex: 0 0 auto;
  border: 1.5px solid var(--excel-muted);
  border-radius: 50%;
  position: relative;
  opacity: 0.75;
}

.lot-yt-icon::after {
  content: "";
  position: absolute;
  width: 0.32rem;
  height: 1.5px;
  background: var(--excel-muted);
  right: -0.18rem;
  bottom: -0.04rem;
  transform: rotate(45deg);
}

.lot-yt-search-bar input[type="search"] {
  flex: 1 1 auto;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0.3rem 0.15rem !important;
  background: transparent !important;
  min-width: 0;
  min-height: auto;
  width: auto;
}

.lot-yt-search-bar input[type="search"]::-webkit-search-cancel-button {
  display: none;
}

.lot-yt-clear {
  border: 0;
  background: transparent;
  color: var(--excel-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
}

.lot-yt-clear:hover {
  color: #222;
}

.lot-yt-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  z-index: 40;
  max-height: 14rem;
  overflow: auto;
  border: 1px solid var(--excel-border-dark);
  background: #fff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.lot-yt-suggestion {
  display: grid;
  grid-template-columns: 3.6rem 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.4rem;
  row-gap: 0.05rem;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #eee;
  background: #fff;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.lot-yt-suggestion:last-child {
  border-bottom: 0;
}

.lot-yt-suggestion:hover,
.lot-yt-suggestion.is-active {
  background: var(--excel-select);
}

.lot-yt-suggestion-kind {
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--excel-green-dark);
}

.lot-yt-suggestion-main {
  font-size: 0.82rem;
  font-weight: 600;
  color: #222;
}

.lot-yt-suggestion-meta {
  font-size: 0.7rem;
  color: var(--excel-muted);
}

.lot-yt-mark {
  background: #dcefdd;
  color: #14532d;
  padding: 0 0.05rem;
}

.lot-yt-empty {
  padding: 0.55rem 0.65rem;
  font-size: 0.8rem;
  color: var(--excel-muted);
}

.lot-yt-selected {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  padding: 0.3rem 0.45rem;
  background: var(--excel-green-light);
  border: 1px solid #c8e6c9;
  font-size: 0.8rem;
}

.lot-yt-selected-clear {
  margin-left: auto;
  border: 1px solid var(--excel-border-dark);
  background: #fff;
  font: inherit;
  font-size: 0.72rem;
  padding: 0.1rem 0.4rem;
  cursor: pointer;
}

.lot-data-section {
  margin-top: 0.25rem;
}

.lot-data-tabs-row {
  margin-bottom: 0.5rem;
}

.lot-data-tabs .mode-btn {
  min-width: 6.5rem;
  text-align: center;
}

.lot-data-panel.hidden {
  display: none !important;
}

.lot-stock-row {
  cursor: pointer;
}

.lot-stock-row:hover {
  background: var(--excel-select);
}

.lot-stock-row:focus {
  outline: 2px solid var(--excel-green);
  outline-offset: -2px;
}

.lot-pl-muted { color: var(--excel-muted); }
.lot-pl-profit { color: #1b5e20; font-weight: 600; }

.lot-table-wrap {
  overflow-x: auto;
  margin-bottom: 0.5rem;
  border: 1px solid var(--excel-border);
}

.lot-table th {
  white-space: nowrap;
}

.lot-table td.num,
.lot-table th.num {
  text-align: right;
}

@media (max-width: 900px) {
  .lot-sale-form {
    max-width: none;
  }

  .lot-sales-kpis {
    order: 3;
    width: 100%;
    margin-left: 0;
  }

  .lot-data-tabs {
    width: 100%;
  }

  .lot-data-tabs .mode-btn {
    flex: 1 1 0;
  }
}

@media (max-width: 560px) {
  #sheetLotSales .section-head-row {
    flex-direction: column;
    align-items: stretch;
  }

  .lot-sale-fields {
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem 0.5rem;
  }

  .lot-field-submit .ribbon-btn {
    min-height: 2.4rem;
  }

  .lot-yt-search-bar,
  .lot-sale-form input,
  .lot-sale-form select {
    min-height: 2.4rem;
  }

  .lot-yt-search-bar input[type="search"] {
    font-size: 16px;
  }

  .lot-sale-form input,
  .lot-sale-form select {
    font-size: 16px;
  }
}

.landing-action-btn-inventory {
  background: linear-gradient(180deg, #e8f5e9 0%, #c8e6c9 100%);
  color: #1b5e20;
  border-color: #81c784;
}

.landing-action-btn-inventory:hover {
  background: linear-gradient(180deg, #c8e6c9 0%, #a5d6a7 100%);
  border-color: #43a047;
}

.landing-action-btn-inventory-reverse {
  background: linear-gradient(180deg, #fff8e1 0%, #ffecb3 100%);
  color: #e65100;
  border-color: #ffb74d;
}

.landing-action-btn-inventory-reverse:hover {
  background: linear-gradient(180deg, #ffecb3 0%, #ffe082 100%);
  border-color: #fb8c00;
}
