:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: #20252b;
  background: #f4f5f6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: #f4f5f6;
}

button,
input {
  font: inherit;
}

select {
  font: inherit;
}

button,
a,
input {
  outline-offset: 2px;
}

.topbar {
  border-bottom: 1px solid #d9dde1;
  background: #ffffff;
}

.topbar-inner {
  width: min(1040px, calc(100% - 32px));
  min-height: 68px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-block {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.brand-block strong {
  font-size: 18px;
  line-height: 1.4;
}

.brand-block span {
  color: #69727b;
  font-size: 14px;
  white-space: nowrap;
}

.topbar-actions,
.command-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quiet-link {
  color: #315b7d;
  font-size: 14px;
  text-decoration: none;
}

.quiet-link:hover {
  text-decoration: underline;
}

.page-shell {
  width: min(1040px, calc(100% - 32px));
  margin: 24px auto 56px;
}

.sync-strip {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid #d9dde1;
  color: #59636d;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #9aa2a9;
}

.status-dot.online {
  background: #238253;
}

.status-dot.stale {
  background: #b56a15;
}

.message {
  margin-top: 18px;
  padding: 11px 13px;
  border-left: 3px solid #315b7d;
  background: #eaf1f6;
  color: #23445e;
  font-size: 14px;
}

.message.error {
  border-color: #b33a36;
  background: #f9eaea;
  color: #7d2926;
}

.auth-panel {
  width: min(420px, 100%);
  margin: 56px auto 0;
  padding: 28px;
  border: 1px solid #d5d9dd;
  border-radius: 6px;
  background: #ffffff;
}

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

.auth-panel h1,
.editor h1 {
  margin-bottom: 24px;
  font-size: 22px;
  line-height: 1.35;
}

.auth-panel form {
  display: grid;
  gap: 10px;
}

.auth-panel label,
.amount-label {
  color: #4f5962;
  font-size: 13px;
  font-weight: 600;
}

input[type="password"],
input[type="number"] {
  width: 100%;
  height: 42px;
  border: 1px solid #bcc3c9;
  border-radius: 4px;
  background: #ffffff;
  color: #20252b;
  padding: 0 11px;
}

.item-adjustment-control select {
  height: 34px;
  border: 1px solid #bcc3c9;
  border-radius: 4px;
  background: #ffffff;
  color: #20252b;
  padding: 0 5px;
}

input:focus,
.item-adjustment-control select:focus {
  border-color: #315b7d;
  box-shadow: 0 0 0 2px rgba(49, 91, 125, 0.14);
}

.auth-panel .primary-button {
  margin-top: 12px;
}

.primary-button,
.secondary-button {
  min-height: 38px;
  border-radius: 4px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 600;
}

.primary-button {
  border: 1px solid #8f5d20;
  background: #9d6827;
  color: #ffffff;
}

.primary-button:hover {
  background: #83551d;
}

.secondary-button {
  border: 1px solid #aeb5bb;
  background: #ffffff;
  color: #35404a;
}

.secondary-button:hover {
  background: #eef0f2;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.editor {
  margin-top: 34px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid #cfd4d8;
}

.section-heading h1 {
  margin-bottom: 5px;
}

.section-heading p {
  margin-bottom: 0;
  color: #6a737b;
  font-size: 13px;
}

.adjustment-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  padding: 26px 0 30px;
}

.adjustment-control {
  min-width: 0;
  margin: 0;
  padding: 20px;
  border: 1px solid #cfd4d8;
  border-radius: 6px;
  background: #ffffff;
}

.adjustment-control legend {
  padding: 0 7px;
  font-size: 16px;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  height: 38px;
  margin-bottom: 18px;
  border: 1px solid #aeb5bb;
  border-radius: 4px;
  overflow: hidden;
}

.segmented label {
  min-width: 0;
  cursor: pointer;
}

.segmented label + label {
  border-left: 1px solid #aeb5bb;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4b555e;
  font-size: 14px;
}

.segmented input:checked + span {
  background: #315b7d;
  color: #ffffff;
}

.segmented input:focus-visible + span {
  outline: 2px solid #315b7d;
  outline-offset: -3px;
}

.amount-label {
  display: block;
  margin-bottom: 7px;
}

.preview-section {
  border-top: 1px solid #cfd4d8;
  padding-top: 26px;
}

.preview-section h2 {
  margin-bottom: 14px;
  font-size: 17px;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid #cfd4d8;
  background: #ffffff;
}

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  table-layout: fixed;
}

th:nth-child(1),
td:nth-child(1) {
  width: 120px;
}

th:nth-child(n + 2):nth-child(-n + 5),
td:nth-child(n + 2):nth-child(-n + 5) {
  width: 125px;
}

th:nth-child(6),
th:nth-child(7),
td:nth-child(6),
td:nth-child(7) {
  width: 190px;
}

th,
td {
  height: 44px;
  padding: 8px 13px;
  border-bottom: 1px solid #e0e3e5;
  text-align: right;
  white-space: nowrap;
}

th {
  background: #f0f2f3;
  color: #4d5760;
  font-size: 13px;
}

th:first-child,
td:first-child {
  text-align: left;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.adjusted-value {
  color: #8c5718;
  font-weight: 700;
}

.item-adjustment-cell {
  padding: 5px 7px;
}

.item-adjustment-control {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 5px;
  width: 100%;
  min-width: 0;
}

.item-adjustment-control .item-adjustment-amount {
  height: 34px;
  min-width: 0;
  padding: 0 7px;
}

@media (max-width: 680px) {
  .topbar-inner,
  .page-shell {
    width: min(100% - 24px, 1040px);
  }

  .topbar-inner,
  .brand-block,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-inner {
    padding: 14px 0;
    gap: 10px;
  }

  .brand-block {
    gap: 3px;
  }

  .topbar-actions,
  .command-row {
    width: 100%;
    justify-content: space-between;
  }

  .adjustment-grid {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    margin-top: 32px;
    padding: 22px;
  }
}
