:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --text: #17201a;
  --muted: #657066;
  --line: #dce1da;
  --accent: #0f7a66;
  --accent-strong: #095d4e;
  --warn: #b45309;
  --danger: #b42318;
  --soft: #e8f2ee;
  --shadow: 0 18px 45px rgba(22, 35, 28, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button,
.file-label,
.header-link {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 40px;
  padding: 0 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  text-align: center;
  max-width: 100%;
  text-decoration: none;
}

button:hover,
.file-label:hover,
.header-link:hover {
  background: var(--accent-strong);
}

.ghost {
  background: #ffffff;
  color: var(--accent-strong);
  border: 1px solid var(--line);
}

.ghost:hover {
  background: var(--soft);
}

.setup-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.file-label input {
  display: none;
}

body.modal-open {
  overflow: hidden;
}

.app-modal {
  align-items: center;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 50;
}

.app-modal[hidden] {
  display: none;
}

.app-modal__backdrop {
  background: rgba(23, 32, 26, 0.42);
  inset: 0;
  position: absolute;
}

.app-modal__panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 28px 80px rgba(22, 35, 28, 0.24);
  display: grid;
  gap: 14px;
  grid-template-columns: 42px minmax(0, 1fr);
  max-width: 460px;
  padding: 18px;
  position: relative;
  transform: translateY(8px);
  transition: transform 0.14s ease, opacity 0.14s ease;
  width: min(100%, 460px);
  opacity: 0;
}

.app-modal.open .app-modal__panel {
  opacity: 1;
  transform: translateY(0);
}

.app-modal__icon {
  align-items: center;
  background: var(--soft);
  border-radius: 50%;
  color: var(--accent-strong);
  display: flex;
  font-size: 20px;
  font-weight: 900;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.app-modal.danger .app-modal__icon {
  background: #fff0f0;
  color: var(--danger);
}

.app-modal.warn .app-modal__icon {
  background: #fff7ed;
  color: var(--warn);
}

.app-modal__body {
  min-width: 0;
}

.app-modal__body h2 {
  font-size: 18px;
  margin: 0 0 8px;
}

.app-modal__message {
  color: var(--muted);
  display: grid;
  font-size: 14px;
  gap: 6px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.app-modal__message p {
  margin: 0;
}

.app-modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.app-modal__actions button {
  min-width: 88px;
}

.app-modal.danger #appModalConfirm {
  background: var(--danger);
}

.app-modal.danger #appModalConfirm:hover {
  background: #8f1d14;
}

.app-header {
  padding: 28px clamp(18px, 4vw, 48px) 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.layout {
  padding: 0 clamp(18px, 4vw, 48px) 48px;
}

.page-tabs {
  background: rgba(246, 247, 244, 0.94);
  display: flex;
  gap: 8px;
  margin: 6px 0 14px;
  overflow-x: auto;
  padding: 4px 0 8px;
  position: sticky;
  top: 0;
  z-index: 4;
}

.tab-button {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--accent-strong);
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 14px;
}

.tab-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.segmented button {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  min-height: 32px;
  padding: 0 12px;
}

.segmented button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

[hidden] {
  display: none !important;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 10px 0 18px;
}

.summary-grid article,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-grid article {
  padding: 18px;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.summary-grid strong {
  font-size: 24px;
  line-height: 1.1;
}

.analytics-filter {
  margin-bottom: 12px;
}

.record-filter {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(140px, 180px) minmax(140px, 180px) auto;
}

.record-filter label {
  margin: 0;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.analytics-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.analytics-grid span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
}

.analytics-grid strong {
  font-size: 20px;
  line-height: 1.15;
}

.inventory-adjust-box {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 14px;
}

.investment-box {
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  padding-bottom: 14px;
}

.inventory-filter {
  margin: 0 0 12px;
}

.price-sort {
  margin: 0 0 12px;
}

.inventory-adjust-box h3,
.investment-box h3 {
  font-size: 15px;
  margin: 0 0 10px;
}

.section-note {
  color: var(--muted);
  font-size: 13px;
  margin: -4px 0 10px;
}

.inventory-adjust-form,
.investment-form {
  align-items: end;
  margin-bottom: 12px;
}

.inventory-adjust-wrap table,
.investment-wrap table {
  min-width: 720px;
}

.investment-wrap table {
  min-width: 520px;
}

.negative {
  color: var(--danger);
}

.negative-stock-row td {
  background: #fff6f6;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

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

.panel-title p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 34px;
  padding: 6px 8px;
  color: var(--text);
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 122, 102, 0.22);
  border-color: var(--accent);
}

textarea {
  line-height: 1.25;
  overflow: hidden;
  resize: none;
}

.name-field {
  min-height: 42px;
  white-space: normal;
  word-break: break-all;
}

.product-table-wrap,
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.compact-table table {
  table-layout: fixed;
}

.compact-table th:first-child,
.compact-table td:first-child {
  width: 26%;
}

.compact-table small {
  color: var(--muted);
  font-size: 12px;
}

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

.purchase-draft-wrap table {
  min-width: 760px;
}

.purchase-draft-wrap td:nth-child(2) > div + div {
  margin-top: 6px;
}

.pending-sale-wrap table {
  min-width: 1040px;
}

.pending-sale-wrap th:first-child,
.pending-sale-wrap td:first-child {
  width: 92px;
}

.pending-sale-wrap th:nth-child(2),
.pending-sale-wrap td:nth-child(2) {
  width: 220px;
}

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

.row-actions button {
  min-height: 32px;
  padding: 0 10px;
}

.initial-table {
  min-width: 620px;
  table-layout: fixed;
}

.price-table {
  min-width: 450px;
  table-layout: fixed;
}

.initial-table th:nth-child(1),
.initial-table td:nth-child(1) {
  width: 48px;
}

.initial-table th:nth-child(2),
.initial-table td:nth-child(2) {
  width: 240px;
}

.price-table th,
.price-table td {
  padding: 4px 3px;
  text-align: center;
}

.price-table th:nth-child(1),
.price-table td:nth-child(1) {
  width: 38px;
}

.price-table th:nth-child(2),
.price-table td:nth-child(2) {
  text-align: left;
  width: 155px;
}

.price-table th:nth-child(3),
.price-table td:nth-child(3) {
  width: 58px;
}

.price-table th:nth-child(4),
.price-table td:nth-child(4) {
  width: 58px;
}

.price-table th:nth-child(5),
.price-table td:nth-child(5) {
  width: 62px;
}

.price-table th:nth-child(6),
.price-table td:nth-child(6) {
  width: 58px;
}

.price-table .delete-btn {
  min-height: 28px;
  padding: 0 8px;
}

.initial-table th:nth-child(3),
.initial-table td:nth-child(3) {
  width: 108px;
  text-align: center;
}

.initial-table th:nth-child(4),
.initial-table td:nth-child(4),
.initial-table th:nth-child(5),
.initial-table td:nth-child(5) {
  width: 112px;
  text-align: center;
}

.initial-table input {
  min-width: 0;
  text-align: center;
}

.initial-table .initial-product-name {
  font-weight: 700;
  text-align: left;
}

.price-table input {
  min-width: 0;
  text-align: center;
}

.price-table input,
.price-table textarea {
  border-radius: 6px;
  min-height: 28px;
  padding: 3px 5px;
}

.price-table .name-field {
  line-height: 1.15;
  min-height: 28px;
  text-align: left;
}

.price-table .stock-count,
.price-table .sales-count {
  align-items: center;
  display: inline-flex;
  font-size: 13px;
  justify-content: center;
  min-height: 28px;
  white-space: nowrap;
}

.initial-table small,
.price-table small {
  color: var(--muted);
  font-size: 12px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 7px 6px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

td input {
  min-width: 110px;
}

.product-table:not(.sale-table) {
  font-size: 13px;
  table-layout: fixed;
  width: max-content;
  min-width: 970px;
}

.sale-table {
  font-size: 13px;
  table-layout: fixed;
  width: max-content;
  min-width: 898px;
}

.product-table:not(.sale-table) th,
.product-table:not(.sale-table) td,
.sale-table th,
.sale-table td {
  padding: 2px 3px;
  text-align: center;
  vertical-align: middle;
}

.product-table:not(.sale-table) th:nth-child(1),
.product-table:not(.sale-table) td:nth-child(1),
.sale-table th:nth-child(1),
.sale-table td:nth-child(1) {
  width: 34px;
}

.product-table:not(.sale-table) th:nth-child(2),
.product-table:not(.sale-table) td:nth-child(2),
.sale-table th:nth-child(2),
.sale-table td:nth-child(2) {
  text-align: left;
  width: 430px;
}

.product-table:not(.sale-table) th:nth-child(3),
.product-table:not(.sale-table) td:nth-child(3),
.sale-table th:nth-child(3),
.sale-table td:nth-child(3) {
  width: 82px;
}

.product-table:not(.sale-table) th:nth-child(4),
.product-table:not(.sale-table) td:nth-child(4),
.sale-table th:nth-child(4),
.sale-table td:nth-child(4) {
  width: 76px;
}

.product-table:not(.sale-table) th:nth-child(5),
.product-table:not(.sale-table) td:nth-child(5),
.sale-table th:nth-child(5),
.sale-table td:nth-child(5) {
  width: 82px;
}

.sale-table th:nth-child(6),
.sale-table td:nth-child(6) {
  width: 120px;
}

.sale-table th:nth-child(7),
.sale-table td:nth-child(7) {
  width: 64px;
}

.product-table:not(.sale-table) th:nth-child(6),
.product-table:not(.sale-table) td:nth-child(6) {
  width: 82px;
}

.product-table:not(.sale-table) th:nth-child(7),
.product-table:not(.sale-table) td:nth-child(7) {
  width: 120px;
}

.product-table:not(.sale-table) th:nth-child(8),
.product-table:not(.sale-table) td:nth-child(8) {
  width: 64px;
}

.product-table:not(.sale-table) input {
  border-radius: 6px;
  min-height: 28px;
  min-width: 0;
  padding: 3px 5px;
  text-align: center;
}

.sale-table input {
  border-radius: 6px;
  min-height: 28px;
  min-width: 0;
  padding: 3px 5px;
  text-align: center;
}

.product-table:not(.sale-table) textarea {
  border-radius: 6px;
}

.product-table:not(.sale-table) td:nth-child(2) input,
.product-table:not(.sale-table) td:nth-child(2) textarea,
.product-table:not(.sale-table) td:nth-child(7) input,
.product-table:not(.sale-table) td:nth-child(7) textarea,
.sale-table td:nth-child(2) input,
.sale-table td:nth-child(6) input {
  text-align: left;
}

.row-delete-btn {
  min-height: 28px;
  padding: 0 8px;
  width: 100%;
}

.product-table:not(.sale-table) .name-field,
.sale-table .name-field {
  font-size: 13px;
  line-height: 1.15;
  min-height: 30px;
  padding: 3px 5px;
  white-space: nowrap;
  word-break: normal;
}

.product-code {
  width: 64px;
  font-weight: 800;
}

.price-compare {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  font-size: 11px;
  gap: 1px;
  justify-content: center;
  line-height: 1.1;
  min-height: 28px;
  white-space: nowrap;
}

.price-compare strong,
.price-diff {
  font-size: 11px;
}

.price-compare .up,
.price-diff.up {
  color: var(--danger);
}

.price-compare .down,
.price-diff.down {
  color: var(--accent-strong);
}

.price-compare .same,
.price-diff.same,
.compare-muted {
  color: var(--muted);
}

.status {
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.status.done {
  background: var(--soft);
  color: var(--accent-strong);
}

.status.open {
  background: #fff7ed;
  color: var(--warn);
}

.entry-bottom-controls {
  align-items: end;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(180px, 260px);
  margin-top: 10px;
  padding-top: 12px;
}

.shipping-required input {
  border-color: var(--accent);
  background: #f8fffc;
}

.delete-btn {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--danger);
  min-height: 34px;
  padding: 0 10px;
}

.delete-btn:hover {
  background: #fff1f0;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.inline-total {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  justify-content: flex-end;
  margin-top: 10px;
  padding-top: 12px;
}

.inline-total span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.inline-total strong {
  font-size: 18px;
}

.add-row-btn {
  background: #fff;
  border: 1px dashed var(--accent);
  color: var(--accent-strong);
  margin-top: 10px;
  width: 100%;
}

.add-row-btn:hover {
  background: var(--soft);
}

@media (max-width: 980px) {
  .workspace,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .app-header,
  .panel-title {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .header-actions > * {
    flex: 1;
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .app-modal {
    align-items: flex-end;
    padding: 12px;
  }

  .app-modal__panel {
    border-radius: 10px;
    grid-template-columns: 36px minmax(0, 1fr);
    padding: 16px;
  }

  .app-modal__icon {
    font-size: 18px;
    height: 36px;
    width: 36px;
  }

  .app-modal__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .app-header {
    padding: 18px 12px 12px;
    gap: 14px;
    overflow: hidden;
  }

  h1 {
    font-size: 30px;
  }

  h2 {
    font-size: 16px;
  }

  .eyebrow {
    font-size: 12px;
  }

  .layout {
    padding: 0 12px 32px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  .summary-grid article {
    min-width: 0;
    padding: 10px;
  }

  .summary-grid span {
    font-size: 12px;
    min-height: 32px;
  }

  .summary-grid strong {
    font-size: 20px;
    word-break: break-word;
  }

  .panel {
    min-width: 0;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: 0 8px 22px rgba(22, 35, 28, 0.06);
    width: 100%;
  }

  .panel-title {
    gap: 10px;
    margin-bottom: 12px;
  }

  .panel-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .record-filter {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .panel-title button {
    width: 100%;
  }

  .form-grid {
    gap: 8px;
  }

  input,
  select,
  textarea,
  button,
  .file-label {
    min-height: 40px;
  }

  input,
  select,
  textarea {
    min-width: 0;
  }

  .workspace {
    min-width: 0;
    width: 100%;
  }

  .product-table-wrap,
  .table-wrap {
    overflow: visible;
  }

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

  .initial-table,
  .initial-table tbody,
  .initial-table tr,
  .initial-table td {
    display: block;
    min-width: 0;
    width: 100%;
  }

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

  .initial-table thead {
    display: none;
  }

  .initial-table tr {
    display: grid;
    grid-template-columns: 30px repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line);
  }

  .initial-table td {
    border: 0;
    padding: 0;
  }

  .initial-table td:nth-child(1) {
    align-self: center;
    grid-row: 1 / 3;
  }

  .initial-table td:nth-child(2) {
    align-self: center;
    grid-column: 2 / -1;
    text-align: left;
  }

  .initial-table td:nth-child(3),
  .initial-table td:nth-child(4),
  .initial-table td:nth-child(5) {
    grid-column: span 1;
    text-align: center;
  }

  .initial-table td:nth-child(3)::before,
  .initial-table td:nth-child(4)::before,
  .initial-table td:nth-child(5)::before {
    color: var(--muted);
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 800;
    margin-bottom: 3px;
  }

  .initial-table input {
    min-height: 28px;
    padding: 3px 5px;
  }

  .initial-table strong {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
  }

  .price-table,
  .price-table tbody,
  .price-table tr,
  .price-table td {
    display: block;
    min-width: 0;
    width: 100%;
  }

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

  .price-table thead {
    display: none;
  }

  .price-table tr {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) 52px 52px 60px 48px;
    gap: 4px;
    padding: 3px 0;
    border-bottom: 1px solid var(--line);
    align-items: center;
  }

  .price-table td {
    border: 0;
    padding: 0;
  }

  .price-table td:nth-child(1) {
    align-self: center;
    grid-row: auto;
    text-align: left;
  }

  .price-table td:nth-child(2) {
    grid-column: 2 / 3;
  }

  .price-table td:nth-child(3) {
    grid-column: 3 / 4;
  }

  .price-table td:nth-child(4) {
    grid-column: 4 / 5;
  }

  .price-table td:nth-child(5) {
    grid-column: 5 / 6;
  }

  .price-table td:nth-child(6) {
    grid-column: 6 / -1;
  }

  .price-table td:nth-child(3)::before,
  .price-table td:nth-child(4)::before,
  .price-table td:nth-child(5)::before,
  .price-table td:nth-child(6)::before {
    display: none;
  }

  .product-table,
  .product-table tbody,
  .product-table tr,
  .product-table td {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .product-table:not(.sale-table) {
    min-width: 0;
    width: 100%;
  }

  .product-table thead {
    display: none;
  }

  .product-table tr {
    display: grid;
    grid-template-columns: 30px 110px 82px 100px 230px;
    gap: 3px;
    min-width: 560px;
    padding: 4px 0;
    border-bottom: 1px solid var(--line);
  }

  .product-table td {
    border: 0;
    padding: 0;
  }

  .product-table:not(.sale-table) th,
  .product-table:not(.sale-table) td {
    width: 100%;
  }

  .product-table td:nth-child(1) {
    align-self: center;
    grid-row: 1 / 4;
  }

  .product-table td:nth-child(2)::before,
  .product-table td:nth-child(3)::before,
  .product-table td:nth-child(4)::before,
  .product-table td:nth-child(5)::before,
  .product-table td:nth-child(6)::before,
  .product-table td:nth-child(7)::before,
  .product-table td:nth-child(8)::before {
    color: var(--muted);
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 800;
    margin-bottom: 3px;
  }

  .product-table td:nth-child(2) {
    grid-column: 2 / -1;
  }

  .product-table td:nth-child(3) {
    grid-column: 2 / 3;
    grid-row: 2;
  }

  .product-table td:nth-child(4) {
    grid-column: 3 / 4;
    grid-row: 2;
  }

  .product-table td:nth-child(5) {
    grid-column: 5 / 6;
    grid-row: 2;
  }

  .product-table td:nth-child(6) {
    grid-column: 4 / 5;
    grid-row: 2;
  }

  .product-table td:nth-child(7) {
    grid-column: 2 / 5;
    grid-row: 3;
  }

  .product-table td:nth-child(8) {
    grid-column: 5 / 6;
    grid-row: 3;
  }

  .sale-table tr {
    grid-template-columns: 30px minmax(0, 1fr) 70px 70px;
    min-width: 0;
  }

  .sale-table td:nth-child(1) {
    align-self: center;
    grid-column: 1;
    grid-row: 1 / 4;
  }

  .sale-table td:nth-child(2) {
    grid-column: 2 / -1;
    min-width: 0;
  }

  .sale-table td:nth-child(3) {
    grid-column: 2 / 3;
    grid-row: 2;
  }

  .sale-table td:nth-child(4) {
    grid-column: 3 / 4;
    grid-row: 2;
  }

  .sale-table td:nth-child(5) {
    grid-column: 4 / 5;
    grid-row: 2;
  }

  .sale-table td:nth-child(6) {
    grid-column: 2 / 4;
    grid-row: 3;
  }

  .sale-table td:nth-child(7) {
    grid-column: 4 / 5;
    grid-row: 3;
  }

  .sale-table td:nth-child(7)::before {
    display: none;
  }

  .product-table input,
  .product-table textarea {
    min-height: 28px;
    padding: 3px 5px;
  }

  .name-field {
    min-height: 30px;
  }

  .product-code {
    font-size: 13px;
    width: auto;
  }

  .table-wrap table,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: 100%;
  }

  .pending-sale-wrap table {
    min-width: 0;
  }

  .purchase-draft-wrap table {
    min-width: 0;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 10px;
    min-width: 0;
    padding: 10px;
  }

  .table-wrap td {
    align-items: flex-start;
    border: 0;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    min-width: 0;
    overflow-wrap: anywhere;
    padding: 7px 0;
  }

  .table-wrap td::before {
    color: var(--muted);
    content: attr(data-label);
    flex: 0 0 88px;
    font-size: 12px;
    font-weight: 800;
  }

  .table-wrap td:first-child {
    padding-top: 0;
  }

  .table-wrap td:last-child {
    padding-bottom: 0;
  }

  .table-wrap td:last-child::before,
  .table-wrap td.empty::before {
    content: "";
    display: none;
  }

  .smart-restock-wrap td {
    display: grid;
    gap: 4px 10px;
    grid-template-columns: 72px minmax(0, 1fr);
    justify-content: stretch;
  }

  .smart-restock-wrap td::before {
    flex: none;
  }

  .smart-restock-wrap td strong {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .smart-restock-wrap td:first-child,
  .smart-restock-wrap td:last-child {
    grid-template-columns: 1fr;
  }

  .smart-restock-wrap td:first-child::before,
  .smart-restock-wrap td:last-child::before {
    content: attr(data-label);
    display: block;
  }

  .inventory-wrap td {
    display: grid;
    gap: 4px 10px;
    grid-template-columns: 72px minmax(0, 1fr);
    justify-content: stretch;
  }

  .inventory-wrap td::before {
    flex: none;
  }

  .inventory-wrap td strong {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .inventory-wrap td:first-child {
    grid-template-columns: 1fr;
  }

  .inventory-wrap td:first-child::before {
    content: attr(data-label);
    display: block;
  }

  .delete-btn {
    width: 100%;
  }

  .empty {
    display: block;
    padding: 18px 8px;
    text-align: center;
  }

  .inline-total {
    gap: 6px 10px;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 10px;
  }

  .entry-bottom-controls {
    grid-template-columns: 1fr;
  }

  .inline-total span {
    font-size: 12px;
  }

  .inline-total strong {
    font-size: 16px;
  }
}

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

  .panel-actions,
  .header-actions {
    grid-template-columns: 1fr;
  }
}


/* product-profit-extension */
.price-table {
  min-width: 560px;
}

.price-table th:nth-child(5),
.price-table td:nth-child(5) {
  width: 82px;
}

.price-table th:nth-child(6),
.price-table td:nth-child(6) {
  width: 62px;
}

.price-table th:nth-child(7),
.price-table td:nth-child(7) {
  width: 58px;
}

.price-table .stock-count,
.price-table .sales-count,
.price-table .purchase-cost {
  align-items: center;
  display: inline-flex;
  flex-direction: column;
  font-size: 13px;
  justify-content: center;
  line-height: 1.15;
  min-height: 28px;
  white-space: nowrap;
}

.price-table .purchase-cost strong {
  font-size: 13px;
}

.price-table .purchase-cost small {
  color: var(--muted);
  font-size: 11px;
}

.profit-estimate-panel {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
}

.profit-estimate-head {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
}

.profit-estimate-head h3 {
  margin: 0 0 3px;
}

.profit-estimate-head p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.profit-rate-label {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 6px;
  font-size: 13px;
  white-space: nowrap;
}

.profit-rate-label input {
  min-height: 32px;
  padding: 4px 8px;
  text-align: center;
  width: 96px;
}

.profit-estimate-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 10px;
}

.profit-estimate-grid article {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
}

.profit-estimate-grid span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}

.profit-estimate-grid strong {
  display: block;
  font-size: 16px;
}

@media (max-width: 760px) {
  .price-table tr {
    grid-template-columns: 24px minmax(0, 1fr) 46px 46px 66px 56px 44px;
  }

  .price-table td:nth-child(6) {
    grid-column: 6 / 7;
  }

  .price-table td:nth-child(7) {
    grid-column: 7 / -1;
  }

  .price-table td:nth-child(7)::before {
    display: none;
  }

  .profit-estimate-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profit-rate-label {
    align-items: flex-start;
    flex-wrap: wrap;
    white-space: normal;
  }
}


.manual-receivable-box {
  align-items: end;
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(160px, 0.7fr) minmax(0, 2fr);
  margin: 8px 0 12px;
  padding: 10px 0;
}

.manual-receivable-box h3 {
  margin: 0 0 3px;
}

.manual-receivable-box p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.manual-receivable-form {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: 130px 150px minmax(160px, 1fr) auto;
}

.manual-receivable-form label {
  font-size: 13px;
}

.manual-receivable-form input {
  min-height: 34px;
}

@media (max-width: 760px) {
  .manual-receivable-box,
  .manual-receivable-form {
    grid-template-columns: 1fr;
  }
}


/* manual-receivable-emphasis */
.manual-receivable-box {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-left: 5px solid #f97316;
  border-radius: 8px;
  padding: 12px;
}

.manual-receivable-box h3 {
  align-items: center;
  color: #9a3412;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.manual-receivable-box p {
  color: #9a3412;
}

.manual-receivable-badge {
  background: #ffedd5;
  border: 1px solid #fdba74;
  border-radius: 999px;
  color: #9a3412;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 5px 8px;
}

.manual-receivable-form button {
  background: #c2410c;
}

.revert-btn {
  min-height: 32px;
  padding: 0 10px;
}


/* manual-receivable-reposition */
.sale-table + .inline-total + .add-row-btn + .manual-receivable-box {
  margin-top: 14px;
}


/* thb-pool-and-cost-rate */
.product-price-actions {
  align-items: center;
  gap: 8px;
}

.cost-rate-label {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: nowrap;
  font-size: 13px;
  gap: 5px;
  white-space: nowrap;
}

.cost-rate-label input {
  min-height: 32px;
  padding: 4px 7px;
  text-align: center;
  width: 88px;
}

.price-table .purchase-cost.cost-warning strong,
.price-table .purchase-cost.cost-warning em {
  color: #b42318;
}

.price-table .purchase-cost em {
  display: block;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}

.thai-pool-row td {
  background: #f8fffc;
}

.thai-source-title td {
  background: #f7fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.thai-source-row td {
  background: #fff;
}

.thai-source-row.manual-source td {
  background: #fffbeb;
}

.source-pool-note {
  color: var(--muted);
  font-size: 12px;
}

.manual-badge {
  background: #f59e0b;
  border-radius: 999px;
  color: #fff;
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  margin-top: 4px;
  padding: 2px 7px;
}

@media (max-width: 720px) {
  .product-price-actions {
    align-items: stretch;
  }

  .cost-rate-label {
    justify-content: space-between;
    width: 100%;
  }

  .source-pool-note {
    display: block;
    padding: 3px 0;
  }
}


/* collapsible-receipts */
.receipt-table {
  min-width: 760px;
  table-layout: fixed;
}

.receipt-table th:nth-child(1),
.receipt-table td:nth-child(1) {
  width: 132px;
}

.receipt-table th:nth-child(2),
.receipt-table td:nth-child(2) {
  width: 96px;
}

.receipt-table th:nth-child(3),
.receipt-table td:nth-child(3),
.receipt-table th:nth-child(4),
.receipt-table td:nth-child(4) {
  width: 128px;
  text-align: center;
}

.receipt-table th:nth-child(6),
.receipt-table td:nth-child(6) {
  width: 112px;
}

.receipt-summary-row.open td {
  background: #f8fffc;
  border-bottom-color: transparent;
}

.receipt-toggle {
  align-items: center;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  font-weight: 800;
  gap: 8px;
  min-height: 28px;
  padding: 0;
}

.receipt-toggle:hover {
  background: transparent;
  color: var(--primary);
}

.receipt-toggle-icon {
  align-items: center;
  background: #e8f5ef;
  border-radius: 999px;
  color: var(--primary);
  display: inline-flex;
  font-size: 15px;
  height: 22px;
  justify-content: center;
  line-height: 1;
  width: 22px;
}

.receipt-note {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.receipt-actions {
  grid-template-columns: 1fr;
}

.receipt-detail-row td {
  background: #f8fffc;
  padding: 0 8px 10px;
}

.receipt-detail-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 2px 0 0 140px;
}

.receipt-detail-grid article {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.receipt-detail-grid span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 3px;
}

.receipt-detail-grid strong {
  display: block;
  font-size: 14px;
}

@media (max-width: 720px) {
  .receipt-table {
    min-width: 0;
  }

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

  .receipt-detail-row td::before {
    display: none;
  }

  .receipt-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-left: 0;
  }

  .receipt-note {
    white-space: normal;
  }
}


/* requirements-doc-page */
.requirements-panel {
  min-height: 70vh;
}

.requirements-note {
  align-items: center;
  background: #f8fffc;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.requirements-note strong {
  color: var(--primary);
}

.requirements-note span {
  color: var(--muted);
  font-size: 13px;
}

.requirements-frame {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  min-height: 68vh;
  width: 100%;
}

@media (max-width: 720px) {
  .requirements-frame {
    min-height: 72vh;
  }
}
