[hidden] {
  display: none !important;
}
:root {
  --ink: #172a2c;
  --muted: #6b7977;
  --line: #dce3df;
  --green: #176652;
  --paper: #f4f6f2;
  --accent: #dcf18a;
  --red: #a93432;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font:
    14px/1.55 "Microsoft YaHei UI",
    "PingFang SC",
    sans-serif;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 6px;
  padding: 9px 15px;
}
button:hover {
  border-color: var(--green);
  background: #eef4ef;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
input,
select,
textarea {
  min-width: 0;
  width: 100%;
  padding: 10px;
  border: 1px solid #ccd7cf;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #7aa697;
  outline-offset: 1px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}
h1,
h2,
p {
  margin: 0;
}
h1 {
  font-size: 28px;
  letter-spacing: -0.6px;
}
h2 {
  font-size: 21px;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
  margin-bottom: 10px;
}
.primary {
  background: var(--green);
  color: white;
  border-color: var(--green);
}
.primary:hover {
  background: #124d3e;
  color: white;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  background: var(--accent);
  color: #173d30;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  font:
    bold 27px Georgia,
    serif;
}
#login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
#login[hidden] {
  display: none;
}
.login-intro {
  background: #173f37;
  padding: 15vh 10%;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 30px;
}
.login-intro h1 {
  font-size: 42px;
  line-height: 1.5;
  font-weight: 500;
}
.login-intro p {
  color: #bfcdc7;
}
#login-form {
  align-self: center;
  width: min(360px, 85%);
  margin: auto;
  display: grid;
  gap: 24px;
}
#login-error {
  color: var(--red);
}
#workspace {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 100vh;
}
#workspace[hidden] {
  display: none;
}
aside {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 27px 16px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 9px 25px;
  font-weight: 700;
  font-size: 16px;
}
.wordmark small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 3px;
}
nav {
  overflow: auto;
  flex: 1;
}
nav p {
  font-size: 10px;
  color: #89938c;
  margin: 20px 12px 6px;
  letter-spacing: 1.5px;
}
nav button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 9px 12px;
  margin: 3px 0;
  color: #576561;
}
nav button.active {
  background: #e7eee7;
  color: #145a47;
  font-weight: 700;
  border-left: 3px solid var(--green);
}
.aside-bottom {
  border-top: 1px solid var(--line);
  padding: 15px 5px 0;
  font-size: 12px;
  display: grid;
  gap: 10px;
}
main {
  padding: 34px 36px;
  min-width: 0;
}
main > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 25px;
  gap: 12px;
}
#header-actions {
  display: flex;
  gap: 8px;
}
#notice {
  color: var(--red);
  margin-bottom: 14px;
}
#notice:not(:empty) {
  padding: 12px;
  background: #fff5ed;
  border: 1px solid #efdccf;
  border-radius: 6px;
}
#filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 18px;
}
#account-filter { min-width: 200px; max-width: 320px; }
#keyword {
  max-width: 270px;
}
#filters input[type="date"] {
  width: 150px;
}
#content {
  min-height: 300px;
}
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}
table {
  border-collapse: collapse;
  width: 100%;
  white-space: nowrap;
}
th {
  text-align: left;
  background: #edf1eb;
  font-size: 11px;
  letter-spacing: 0.3px;
  color: #617069;
  font-weight: 500;
}
td,
th {
  padding: 14px 15px;
  border-bottom: 1px solid #e8ece7;
}
td {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: #fafcf8;
}
.table-wrap button {
  padding: 5px 9px;
  font-size: 12px;
  margin-right: 4px;
}
.badge {
  display: inline-block;
  padding: 3px 8px;
  background: #edf2eb;
  color: #3d6851;
  border-radius: 4px;
  font-size: 11px;
}
.subtle {
  color: var(--muted);
}
.empty {
  padding: 70px;
  text-align: center;
  color: var(--muted);
  background: white;
  border: 1px dashed var(--line);
  border-radius: 8px;
}
footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 25px;
}
.card {
  padding: 24px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 9px;
}
.card strong {
  font:
    32px/1.6 Georgia,
    serif;
  display: block;
  margin-top: 10px;
}
.card:first-child {
  background: #194c3e;
  color: white;
}
.card p {
  font-size: 12px;
  color: var(--muted);
}
.card:first-child p {
  color: #d3dfd5;
}
.section-title {
  font-size: 16px;
  margin: 25px 0 12px;
}
.banner {
  padding: 18px 22px;
  background: #edf0dc;
  border-left: 3px solid #a3ad47;
  color: #535e32;
  margin-bottom: 20px;
  line-height: 1.8;
}
.good {
  color: var(--green);
}
.bad {
  color: var(--red);
}
dialog {
  border: 0;
  border-radius: 12px;
  width: min(950px, 94vw);
  max-height: 92vh;
  padding: 0;
  box-shadow: 0 25px 100px #102d3644;
}
dialog::backdrop {
  background: #10272bcc;
}
dialog > header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 26px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
#dialog-body {
  padding: 24px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.form-grid label.wide {
  grid-column: 1/-1;
}
.lines {
  margin: 22px 0;
}
.lines td {
  padding: 8px;
}
.lines select {
  min-width: 160px;
}
.lines input {
  min-width: 80px;
}
.lines button {
  white-space: nowrap;
}
.form-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 15px;
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.form-error {
  color: var(--red);
  flex: 1;
  white-space: normal;
}
.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}
.facts div {
  padding: 10px;
  background: #f3f5f1;
}
.facts dt {
  font-size: 11px;
  color: var(--muted);
}
.facts dd {
  margin: 5px 0 0;
  word-break: break-all;
}
.checks {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}
.checks label {
  flex-direction: row;
  align-items: center;
  color: var(--ink);
}
.checks input {
  width: auto;
}
.total-line {
  text-align: right;
  margin-top: 12px;
  font-weight: 700;
}
@media (max-width: 950px) {
  #workspace {
    grid-template-columns: 180px minmax(0, 1fr);
  }
  main {
    padding: 22px 18px;
  }
  .form-grid,
  .facts {
    grid-template-columns: repeat(2, 1fr);
  }
  #filters {
    flex-wrap: wrap;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .login-intro h1 {
    font-size: 30px;
  }
}
@media (max-width: 650px) {
  #login {
    grid-template-columns: 1fr;
  }
  .login-intro {
    padding: 35px;
  }
  .login-intro h1 {
    font-size: 25px;
  }
  #login-form {
    padding: 35px 0;
  }
  #workspace {
    display: block;
  }
  aside {
    height: auto;
    position: static;
    padding: 12px;
  }
  nav {
    display: flex;
    overflow: auto;
  }
  nav p,
  .aside-bottom,
  .wordmark small {
    display: none;
  }
  nav button {
    width: auto;
    white-space: nowrap;
  }
  .wordmark {
    margin: 0 0 10px;
  }
  .form-grid,
  .facts {
    grid-template-columns: 1fr;
  }
  h1 {
    font-size: 23px;
  }
}
@media print {
  body {
    background: white;
  }
  aside,
  main > header,
  #filters,
  #pager,
  #notice,
  button {
    display: none !important;
  }
  #workspace {
    display: block;
  }
  main {
    padding: 0;
  }
  dialog[open] {
    position: absolute;
    inset: 0;
    width: 100%;
    max-height: none;
    overflow: visible;
    box-shadow: none;
  }
  body:has(dialog[open]) #workspace {
    display: none;
  }
  .table-wrap {
    overflow: visible;
  }
  td,
  th {
    padding: 8px;
  }
  .facts {
    grid-template-columns: repeat(3, 1fr);
  }
}
#content .dashboard-cards { grid-template-columns: repeat(auto-fit,minmax(190px,1fr)); }
.dashboard-panel { background:white; border:1px solid #d5ded8; border-radius:12px; padding:24px; margin-top:24px; }
.dashboard-panel label { max-width:280px; margin-bottom:20px; }
.store-comparison-row { display:grid; grid-template-columns:minmax(160px,2fr) minmax(80px,3fr) minmax(95px,1fr); align-items:center; gap:16px; margin:18px 0; }
.store-comparison-row strong { text-align:right; }
.store-bar-track { background:#edf2ef; border-radius:5px; overflow:hidden; }
.store-bar { height:18px; background:#176652; min-width:0; }
.store-bar.negative { background:#b42318; }
@media(max-width:650px) { .store-comparison-row { grid-template-columns:1fr 1fr; } .store-comparison-row span { grid-column:1/-1; } }

.product-search-results{z-index:10000;overflow:auto;background:white;border:1px solid #b7c9c2;border-radius:6px;box-shadow:0 5px 18px #0003;padding:4px;}
.product-search-results button{display:block;width:100%;text-align:left;border:0;padding:9px;white-space:normal;}
.product-search-results button:hover,.product-search-results button.active{background:#e5f1eb;}
.product-search-results small{display:block;color:#62756e;margin-top:4px;}

/* Transfer pricing: leave room for full product labels and formatted amounts. */
@media screen {
  dialog:has(.transfer-price-table) { width: min(1360px, 96vw); max-width: 96vw; }
}
.transfer-price-table { table-layout: fixed; min-width: 1120px; width: 100%; }
.transfer-price-table th:nth-child(1) { width: 28%; }
.transfer-price-table th:nth-child(2) { width: 7%; }
.transfer-price-table th:nth-child(3) { width: 17%; }
.transfer-price-table th:nth-child(4) { width: 14%; }
.transfer-price-table th:nth-child(5) { width: 13%; }
.transfer-price-table th:nth-child(6) { width: 14%; }
.transfer-price-table th:nth-child(7) { width: 7%; }
.transfer-price-table td { vertical-align: top; padding: 8px; white-space: normal; }
.transfer-price-table td input, .transfer-price-table td select { width: 100%; min-width: 0 !important; box-sizing: border-box; }
.transfer-price-table td:not(:first-child) input { text-align: right; font-variant-numeric: tabular-nums; }
.transfer-price-table td small { display: block; margin-top: 6px; white-space: normal; overflow-wrap: anywhere; line-height: 1.5; color: var(--muted); }

/* Price scheme editor: keep amount and remove action in separate columns. */
.lines table:has(.price-mode) { width: 100%; table-layout: fixed; min-width: 0; }
.lines table:has(.price-mode) th:first-child { width: 42%; }
.lines table:has(.price-mode) th:last-child { width: 88px; }
.lines table:has(.price-mode) td { white-space: normal; vertical-align: middle; }
.lines table:has(.price-mode) td select,
.lines table:has(.price-mode) td input { display: block; width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; }
.lines table:has(.price-mode) .price-mode { margin-bottom: 8px; }
.lines table:has(.price-mode) .remove-line { position: static; margin: 0; }
@media (max-width: 600px) {
  .lines table:has(.price-mode) th:first-child { width: 38%; }
  .lines table:has(.price-mode) th:last-child { width: 68px; }
  .lines table:has(.price-mode) td { padding: 5px; }
  .lines table:has(.price-mode) .remove-line { padding: 8px; }
}

/* Price scheme compact single-row layout. */
.lines table:has(.price-mode) { min-width: 640px; }
.lines table:has(.price-mode) th:first-child { width: 32%; }
.lines table:has(.price-mode) th:last-child { width: 88px; }
.lines table:has(.price-mode) td:nth-child(2) { white-space: nowrap; }
.lines table:has(.price-mode) .price-mode { display: inline-block; width: calc(44% - 4px); margin: 0 8px 0 0; vertical-align: middle; }
.lines table:has(.price-mode) .quantity { display: inline-block; width: calc(56% - 4px); margin: 0; vertical-align: middle; }
/* Compact purchase header keeps more product lines visible. */
#business-form.purchase-compact > .banner { padding: 8px 12px; margin-bottom: 12px; line-height: 1.5; }
#business-form.purchase-compact > .form-grid { gap: 10px 14px; }
#business-form.purchase-compact > .form-grid label { gap: 4px; }
#business-form.purchase-compact > .form-grid input,
#business-form.purchase-compact > .form-grid select { padding: 7px 10px; min-height: 34px; }
#business-form.purchase-compact .tender-editor { margin: 2px 0; padding: 6px 10px; }
#business-form.purchase-compact .tender-row { margin: 4px 0; gap: 8px; }
#business-form.purchase-compact .tender-editor button { padding: 6px 10px; }
#business-form.purchase-compact .tender-editor p { margin: 2px 0; line-height: 1.35; }
#business-form.purchase-compact > .lines { margin-top: 12px; }
@media (min-width: 900px) {
  #business-form.purchase-compact > .form-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
}
@media (max-width: 600px) {
  #business-form.purchase-compact > .form-grid input,
  #business-form.purchase-compact > .form-grid select { min-height: 42px; }
}
.product-color-cell { white-space: normal; vertical-align: top; }
.product-color-cell > input[role="combobox"] { display: block; width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; }
.product-color-cell > .add-product-color { display: block; margin-top: 6px; }
.product-color-cell .new-color-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; width: 100%; min-width: 0; box-sizing: border-box; padding: 10px; margin-top: 8px; border: 1px solid #b7c9c2; border-radius: 6px; background: #f3f7f4; white-space: normal; }
.product-color-cell .new-color-panel > input,
.product-color-cell .new-color-panel > select,
.product-color-cell .new-color-panel > button { display: block; width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; margin: 0; }
.product-color-cell .new-color-panel > p { margin: 0; white-space: normal; overflow-wrap: anywhere; }
.product-color-cell .new-color-panel > p:empty { display: none; }

/* Purchase lines: prioritize product/barcode, keep quantity compact. */
:is(#business-form.purchase-compact .lines, #draft-form) table:has(th:nth-child(4)):not(:has(.price-mode)) { width:100%; min-width:580px; table-layout:fixed; }
:is(#business-form.purchase-compact .lines, #draft-form) table:has(th:nth-child(4)):not(:has(.price-mode)) th:first-child { width:auto; }
:is(#business-form.purchase-compact .lines, #draft-form) table:has(th:nth-child(4)):not(:has(.price-mode)) th:nth-child(2) { width:90px; }
:is(#business-form.purchase-compact .lines, #draft-form) table:has(th:nth-child(4)):not(:has(.price-mode)) th:nth-child(3) { width:180px; }
:is(#business-form.purchase-compact .lines, #draft-form) table:has(th:nth-child(4)):not(:has(.price-mode)) th:last-child { width:76px; }
:is(#business-form.purchase-compact .lines, #draft-form) table:has(th:nth-child(4)):not(:has(.price-mode)) td { padding:8px; vertical-align:top; }
:is(#business-form.purchase-compact .lines, #draft-form) table:has(th:nth-child(4)):not(:has(.price-mode)) td > input { width:100%; min-width:0; box-sizing:border-box; }
#business-form.purchase-compact .lines .quantity, #draft-form .draft-quantity { text-align:center; }
#business-form.purchase-compact .lines .remove-line { position:static; margin:0; }
#business-form.purchase-compact #line-total { padding:12px 0; margin:8px 0 0; }
