:root {
  color-scheme: light;
  --bg: #eef2f4;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --ink: #18222b;
  --sub: #63717d;
  --line: #d7e0e6;
  --line-strong: #b9c8d1;
  --blue: #176b8f;
  --blue-dark: #0f4f6d;
  --green: #1f7a55;
  --red: #b42318;
  --amber: #9a5b13;
  --shadow: 0 14px 36px rgba(24, 34, 43, 0.08);
  --control-height: 38px;
  --control-height-sm: 34px;
  --control-height-xs: 30px;
  --control-radius: 6px;
  --control-padding-x: 10px;
  --control-padding-y: 8px;
  --check-size: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Noto Sans JP", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1100px;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}

body:not(.is-authenticated) .app-shell {
  display: none;
}

body.is-authenticated .login-screen {
  display: none;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: #eaf0f3;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(380px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-brand {
  color: var(--ink);
  margin-bottom: 4px;
}

.login-brand h1,
.login-brand p {
  color: var(--ink);
}

.login-error {
  min-height: 20px;
  color: var(--red);
  font-weight: 700;
}

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

button {
  border: 1px solid var(--line-strong);
  border-radius: var(--control-radius);
  min-height: var(--control-height);
  padding: var(--control-padding-y) 12px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  border-color: var(--blue);
}

.language-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: 100%;
  min-height: 34px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.language-switch button {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  min-height: 28px;
  border: 0;
  border-radius: 6px;
  padding: 4px 8px;
  color: #b9c8d1;
  background: transparent;
  font-weight: 800;
}

.language-switch button + button {
  border-left: 0;
}

.language-switch button.active {
  color: #fff;
  background: var(--blue);
  box-shadow: 0 4px 12px rgba(45, 141, 178, 0.26);
}

.permission-editor {
  display: grid;
  gap: 18px;
  margin: 18px 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.permission-editor section {
  display: grid;
  gap: 10px;
}

.permission-editor h3,
.settings-section h3 {
  margin: 0;
  font-size: 15px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 16px;
}

.permission-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  white-space: nowrap;
}

.permission-grid input,
.checkbox-label input {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
}

.settings-section {
  padding: 18px 20px;
  border-top: 1px solid var(--line);
}

.audit-list {
  display: grid;
  margin-top: 10px;
}

.audit-row {
  display: grid;
  grid-template-columns: 150px 120px 140px minmax(160px, 1fr) minmax(180px, 1.4fr);
  gap: 12px;
  align-items: center;
  min-height: 38px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.audit-row:first-child {
  border-top: 0;
}

input,
select,
textarea {
  width: 100%;
  min-height: var(--control-height);
  border: 1px solid var(--line-strong);
  border-radius: var(--control-radius);
  padding: var(--control-padding-y) var(--control-padding-x);
  color: var(--ink);
  background: #fff;
}

input[type="checkbox"] {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: var(--check-size);
  height: var(--check-size);
  min-width: var(--check-size);
  min-height: var(--check-size);
  margin: 0;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  flex: 0 0 var(--check-size);
  vertical-align: middle;
}

input[type="checkbox"]::after {
  content: "";
  width: 9px;
  height: 5px;
  margin-top: -1px;
  border: solid #fff;
  border-width: 0 0 2px 2px;
  opacity: 0;
  transform: rotate(-45deg);
}

input[type="checkbox"]:checked {
  border-color: var(--blue);
  background: var(--blue);
}

input[type="checkbox"]:checked::after {
  opacity: 1;
}

input[readonly] {
  color: #4f5e68;
  background: #f3f6f8;
}

table input,
table select,
table button {
  min-height: var(--control-height-sm);
  border-radius: var(--control-radius);
}

table input:not([type="checkbox"]),
table select {
  padding: 6px 8px;
}

table button {
  padding: 6px 10px;
}

textarea {
  resize: vertical;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 18px 14px;
  color: #fff;
  background: #17242e;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 6px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.session-panel {
  order: 4;
  display: grid;
  gap: 8px;
  margin: 10px 10px 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #d7e2e8;
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-language {
  position: relative;
  z-index: 3;
  order: 3;
  margin: auto 10px 0;
  display: grid;
  gap: 8px;
  color: #d7e2e8;
}

.sidebar-language > span {
  color: #91a6b2;
  font-size: 12px;
  font-weight: 800;
}

.session-panel button {
  min-height: 30px;
  padding: 5px 8px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #2d8db2;
  font-weight: 800;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.1;
}

.brand p {
  margin-top: 2px;
  color: #afbec8;
  font-size: 12px;
}

.role-switch {
  order: 2;
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.role-switch button {
  width: 100%;
  border: 0;
  justify-content: flex-start;
  text-align: left;
  color: #dce7ed;
  background: transparent;
}

.role-switch button.active {
  color: #fff;
  background: var(--blue);
}

.nav-submenu {
  display: grid;
  gap: 6px;
  margin: -2px 0 4px 12px;
  padding: 4px 0 4px 10px;
  border-left: 2px solid rgba(255, 255, 255, 0.14);
}

.nav-submenu[hidden] {
  display: none;
}

.nav-submenu button {
  min-height: 34px;
  padding: 7px 10px;
  color: #b9c8d2;
  font-size: 13px;
}

.nav-submenu button.active {
  color: #fff;
  background: rgba(45, 141, 178, 0.72);
}

main {
  min-width: 0;
  padding: 22px;
}

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

.page-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.page-head h2 {
  flex: 0 0 auto;
  font-size: 24px;
  line-height: 1.15;
}

.page-head p,
.muted {
  color: var(--sub);
  font-size: 13px;
}

.page-head p {
  line-height: 1.3;
  white-space: nowrap;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 110px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-strip[hidden] {
  display: none;
}

.summary-strip div {
  display: grid;
  align-content: center;
  min-height: 56px;
  padding: 8px 12px;
  border-right: 1px solid var(--line);
}

.summary-strip div:last-child {
  border-right: 0;
}

.summary-strip strong {
  display: block;
  font-size: 20px;
}

.summary-strip span {
  color: var(--sub);
  font-size: 12px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.layout.wide {
  grid-template-columns: 360px minmax(760px, 1fr);
}

.warehouse-layout {
  grid-template-columns: minmax(620px, 0.95fr) minmax(0, 1.35fr);
  align-items: start;
}

.warehouse-layout .panel {
  min-width: 0;
  overflow: hidden;
}

.warehouse-layout .warehouse-fields {
  grid-template-columns: minmax(150px, 1fr) minmax(96px, 0.65fr) minmax(96px, 0.65fr);
}

.warehouse-layout .warehouse-fields label:last-child {
  grid-column: 1 / -1;
}

.warehouse-layout .actions {
  flex-wrap: wrap;
}

.warehouse-layout .table-wrap {
  max-width: 100%;
}

.layout.split {
  grid-template-columns: 480px minmax(620px, 1fr);
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

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

.panel-actions .panel-search {
  min-width: 260px;
}

.panel h2 {
  font-size: 17px;
}

.panel h3 {
  font-size: 14px;
}

.panel-subsection-head {
  display: flex;
  align-items: center;
  min-height: 54px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.panel-subsection-head h3,
.panel-subsection-head p {
  margin: 0;
}

.panel-subsection-head p {
  margin-top: 3px;
  font-size: 12px;
}

.card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.card-actions button {
  min-height: 30px;
  padding: 5px 9px;
}

.code-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-right: 8px;
  padding: 2px 7px;
  border: 1px solid #b9c8d1;
  border-radius: 6px;
  color: #18394b;
  background: #eff7fa;
  font-size: 12px;
  font-weight: 800;
}

form.panel {
  padding-bottom: 16px;
}

label,
.form-group {
  display: grid;
  gap: 6px;
  margin: 12px 16px;
  color: #2d3842;
  font-size: 13px;
  font-weight: 700;
}

.field-required:not(label)::after {
  color: #d92d20;
  content: "*";
  font-weight: 800;
}

.field-required:not(label)::after {
  margin-left: 4px;
}

.field-label-title {
  align-items: center;
  display: inline-flex;
  gap: 4px;
  width: fit-content;
}

.required-mark {
  color: #d92d20;
  display: inline-block;
  font-weight: 800;
}

.legacy-field {
  display: none;
}

.form-group > span {
  color: #2d3842;
}

.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #2d3842;
}

.account-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 12px 16px;
  padding: 12px 14px;
  border: 1px solid #c8dde6;
  border-radius: 8px;
  background: #eff7fa;
}

.account-banner span {
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}

.account-banner strong {
  color: #18394b;
  font-size: 17px;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-card {
  min-height: 38px;
  border-color: var(--line-strong);
  background: #fff;
  font-weight: 700;
}

.choice-card.active {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.recipient-picker {
  position: relative;
}

.recipient-suggestions {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  display: none;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 28px rgba(24, 34, 43, 0.16);
}

.recipient-suggestions.open {
  display: block;
}

.recipient-option {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 52px;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
}

.recipient-option:last-child {
  border-bottom: 0;
}

.recipient-option:hover {
  background: #edf7fb;
}

.recipient-option span,
.selected-recipient span {
  color: var(--sub);
  font-size: 12px;
  line-height: 1.45;
}

.recipient-empty {
  padding: 14px;
  color: var(--sub);
  text-align: center;
}

.selected-recipient {
  display: grid;
  gap: 3px;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid #c8dde6;
  border-radius: 6px;
  background: #eff7fa;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 8px;
  align-items: end;
  margin: 12px 16px;
}

.field-row.compact {
  grid-template-columns: 1fr 92px;
  margin: 0;
}

.field-row.compact button {
  padding-right: 8px;
  padding-left: 8px;
}

.field-row label {
  margin: 0;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0 16px;
}

.two-col label {
  margin-right: 0;
  margin-left: 0;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin: 14px 16px 0;
}

.form-actions .primary {
  flex: 1;
}

.address-toolbar {
  display: grid;
  grid-template-columns: 220px minmax(320px, 1fr);
  gap: 10px;
  margin: 12px 16px;
  align-items: end;
}

.address-toolbar label {
  margin: 0;
}

.address-toolbar .search {
  margin: 0;
}

.record-filters {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 150px 150px 150px 82px;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.record-filters input,
.record-filters select {
  min-height: 36px;
}

.record-bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  background: #f8fbfc;
}

.record-bulk-bar strong {
  display: inline-flex;
  align-items: center;
  height: 32px;
  min-width: 82px;
  white-space: nowrap;
}

.record-bulk-bar button {
  min-height: 32px;
  padding: 5px 12px;
  white-space: nowrap;
}

.stock-form {
  display: grid;
  gap: 12px;
  padding: 12px 16px 16px;
  border-bottom: 1px solid var(--line);
}

.stock-form-grid {
  display: grid;
  grid-template-columns: 150px minmax(180px, 1fr) minmax(180px, 1fr) minmax(240px, 1.5fr);
  gap: 10px;
  align-items: end;
}

.stock-form-grid label {
  margin: 0;
}

.stock-item-row select,
.stock-item-row input {
  min-height: 34px;
}

.stock-item-row button {
  white-space: nowrap;
}

.stock-plus {
  color: var(--green);
}

.stock-minus {
  color: var(--red);
}

.select-col {
  width: 42px;
  text-align: center;
}

.select-col input {
  margin: 0 auto;
}

.fee-tab-panel {
  display: none;
}

.fee-tab-panel.active {
  display: block;
}

.fee-list-toolbar,
.fee-report-filters {
  display: grid;
  gap: 10px;
  align-items: end;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.fee-list-toolbar {
  grid-template-columns: minmax(260px, 420px) auto 1fr;
}

.fee-list-toolbar button {
  justify-self: start;
  white-space: nowrap;
}

.fee-report-filters {
  grid-template-columns: 150px 150px minmax(160px, 1fr) minmax(220px, 1.4fr) minmax(160px, 1fr) auto;
}

.fee-report-filters label {
  margin: 0;
}

.fee-report-filters button {
  white-space: nowrap;
}

.fee-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(150px, 1fr) 96px 110px minmax(220px, 1.2fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.fee-form[hidden] {
  display: none;
}

.fee-form label {
  margin: 0;
}

.fee-form button {
  white-space: nowrap;
}

.drawer-fee-form {
  grid-template-columns: 1fr 1fr;
  padding: 0;
  border-bottom: 0;
}

.drawer-fee-form label:first-of-type,
.drawer-fee-form label:last-of-type,
.drawer-fee-form button {
  grid-column: 1 / -1;
}

.fee-drawer-body {
  display: grid;
  gap: 18px;
  padding: 16px;
}

.fee-drawer-body h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.fee-order-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbfd;
}

.fee-order-summary div {
  display: grid;
  gap: 4px;
}

.fee-order-summary span,
.fee-drawer-line span,
.fee-drawer-line small {
  color: var(--sub);
}

.standalone-fee-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.standalone-fee-fields[hidden] {
  display: none;
}

.standalone-fee-fields label:last-child {
  grid-column: 1 / -1;
}

.fee-drawer-lines {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.fee-drawer-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.fee-drawer-line:last-child {
  border-bottom: 0;
}

.fee-drawer-line div:first-child {
  display: grid;
  gap: 4px;
}

.fee-drawer-amount {
  display: grid;
  justify-items: end;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.fee-line-actions {
  display: flex;
  gap: 6px;
}

.fee-line-actions button {
  min-height: 30px;
  padding: 5px 10px;
}

.fee-line-actions .danger {
  color: #c92a2a;
}

.detail-actions {
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px 0;
}

.fee-rule-panel {
  overflow: hidden;
}

.fee-rule-panel > .panel-head {
  min-height: 64px;
}

.fee-rule-panel .panel-head h2 {
  margin: 0 0 3px;
  font-size: 18px;
}

.fee-rule-overview {
  border-top: 1px solid var(--line);
  background: #fff;
}

.fee-rule-overview.compact {
  border: 1px solid var(--line);
  border-radius: 6px;
}

.fee-overview-line {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  min-height: 48px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}

.fee-overview-line:first-child {
  border-top: 0;
}

.fee-overview-line strong {
  font-size: 14px;
  white-space: nowrap;
}

.fee-overview-line > span {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
  color: var(--ink);
  font-weight: 700;
}

.overview-separator {
  color: var(--sub);
  font-style: normal;
}

.rule-muted {
  color: var(--sub);
  font-weight: 700;
}

.fee-rule-table-wrap {
  overflow-x: auto;
}

.fee-rule-table {
  table-layout: fixed;
  width: 100%;
}

.fee-rule-table th,
.fee-rule-table td {
  min-height: 46px;
  vertical-align: middle;
}

.fee-rule-table th:nth-child(1),
.fee-rule-table td:nth-child(1) {
  width: 82px;
  text-align: center;
}

.fee-rule-table th:nth-child(2),
.fee-rule-table td:nth-child(2) {
  width: 190px;
  font-weight: 700;
}

.fee-rule-table th:nth-child(3),
.fee-rule-table td:nth-child(3) {
  width: auto;
}

.fee-rule-table th:nth-child(4),
.fee-rule-table td:nth-child(4) {
  width: 96px;
  text-align: right;
}

.fee-basis-hint {
  display: block;
  margin-top: 3px;
  color: var(--sub);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
}

.rule-status,
.rule-auto-text,
.rule-price-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.rule-status.enabled {
  color: var(--blue);
  background: #eef8fb;
}

.rule-status.disabled {
  color: var(--sub);
  background: #f4f6f7;
}

.rule-summary-main {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-weight: 800;
}

.rule-auto-text {
  color: var(--blue);
  background: #eef8fb;
}

.rule-price-text {
  color: var(--ink);
  background: #fff;
  font-variant-numeric: tabular-nums;
}

.auto-fee-note,
.setting-note {
  margin: 0;
  color: var(--sub);
  font-size: 12px;
  line-height: 1.5;
}

.auto-fee-note {
  padding: 10px 12px;
  border: 1px solid #cde0e8;
  border-radius: 6px;
  color: var(--blue-dark);
  background: #eef8fb;
}

.fee-rule-tools.compact {
  display: grid;
  gap: 10px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.fee-rule-detail {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.fee-rule-detail summary {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 14px;
  cursor: pointer;
  list-style: none;
}

.fee-rule-detail summary::-webkit-details-marker {
  display: none;
}

.fee-rule-detail summary::after {
  content: "+";
  margin-left: auto;
  color: var(--blue);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.fee-rule-detail[open] summary {
  border-bottom: 1px solid var(--line);
}

.fee-rule-detail[open] summary::after {
  content: "-";
}

.fee-rule-detail summary span {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.fee-rule-detail summary strong {
  font-size: 15px;
}

.fee-rule-detail summary em {
  color: var(--sub);
  font-size: 12px;
  font-style: normal;
  white-space: nowrap;
}

.fee-rule-detail-body {
  padding: 12px 14px 14px;
}

.compact-table th,
.compact-table td {
  height: 44px;
}

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

.section-head h3 {
  margin: 0;
  font-size: 16px;
}

.rule-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.rule-toolbar label {
  display: grid;
  gap: 5px;
  min-width: 180px;
  margin: 0;
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}

.rule-toolbar button {
  align-self: end;
}

.fee-rule-edit-list {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.fee-rule-edit-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(180px, 1.2fr) 120px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.fee-rule-edit-row:first-child {
  border-top: 0;
}

.fee-rule-edit-row label {
  margin: 0;
}

.fee-rule-edit-row .fee-rule-row-hint {
  grid-column: 2 / -1;
  margin: -4px 0 0;
  color: var(--sub);
  font-size: 12px;
  line-height: 1.4;
}

.fee-rule-enable {
  font-weight: 800;
}

.lock-toolbar {
  margin-bottom: 0;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: auto;
  min-height: var(--control-height);
  color: var(--ink);
  font-size: 14px;
  white-space: nowrap;
}

.warning-line {
  margin-top: 8px;
  padding: 7px 9px;
  border: 1px solid #f2c98c;
  border-radius: 6px;
  color: #7a3f00;
  background: #fff7e8;
  font-weight: 700;
}

.compact-warning {
  font-size: 12px;
  line-height: 1.35;
}

.compact-empty {
  padding: 16px;
}

.fee-detail-cell {
  min-width: 280px;
}

.fee-line {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}

.fee-line:last-child {
  border-bottom: 0;
}

.fee-line span,
.fee-line small {
  color: var(--sub);
}

.fee-line em {
  color: var(--ink);
  font-style: normal;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.fee-line small {
  grid-column: 1 / -1;
}

.sticky-action-col {
  position: sticky;
  right: 0;
  z-index: 2;
  min-width: 92px;
  background: inherit;
}

thead .sticky-action-col {
  z-index: 3;
  background: var(--soft);
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(520px, 1fr);
  gap: 16px;
  align-items: start;
}

.settings-panel {
  min-width: 0;
}

.settings-links {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.settings-link {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 72px;
  padding: 14px 16px;
  border-color: var(--line-strong);
  background: #fff;
  text-align: left;
}

.settings-link strong {
  color: var(--ink);
  font-size: 16px;
}

.settings-link span {
  color: var(--sub);
  font-size: 13px;
  line-height: 1.35;
}

.settings-link:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.settings-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) 130px minmax(150px, 1fr) minmax(150px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.settings-form label {
  margin: 0;
}

.settings-form button {
  white-space: nowrap;
}

.sort-th {
  width: 100%;
  min-height: 26px;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  font-weight: 800;
}

.warehouse-table .sort-th {
  text-align: inherit;
}

.sort-th.numeric {
  text-align: right;
}

.sort-th::after {
  content: "";
  display: inline-block;
  width: 1em;
  margin-left: 4px;
  color: var(--blue);
}

.sort-th.active[data-direction="asc"]::after {
  content: "▲";
}

.sort-th.active[data-direction="desc"]::after {
  content: "▼";
}

.link-button {
  min-height: 0;
  padding: 0;
  border: 0;
  color: var(--blue);
  background: transparent;
  font-weight: 800;
  text-align: left;
}

.link-button:hover {
  color: var(--blue-dark);
  text-decoration: underline;
}

.preview {
  display: none;
  min-height: 68px;
  margin: 0 16px 14px;
  padding: 10px 12px;
  border: 1px solid #c8dde6;
  border-radius: 6px;
  color: #294250;
  background: #eff7fa;
  font-size: 13px;
  line-height: 1.55;
}

.items-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 16px 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.item-labels {
  display: grid;
  grid-template-columns: minmax(150px, 1.1fr) 84px minmax(120px, 1fr) 64px 48px;
  gap: 8px;
  margin: 0 16px 6px;
  color: var(--sub);
  font-size: 12px;
  font-weight: 800;
}

.item-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.1fr) 84px minmax(120px, 1fr) 64px 48px;
  gap: 8px;
  margin: 0 16px 8px;
  align-items: start;
  position: relative;
  z-index: 1;
}

.item-row .remove-item {
  min-height: 38px;
  padding-right: 0;
  padding-left: 0;
}

.add-item-bottom {
  display: block;
  margin: 4px 16px 12px;
}

.item-code-view,
.item-name-view {
  color: #33424d;
  background: #f6f9fa;
}

.item-row:focus-within {
  z-index: 8;
}

.product-picker {
  position: relative;
}

.product-suggestions {
  position: absolute;
  left: 0;
  right: auto;
  top: calc(100% + 4px);
  z-index: 30;
  display: none;
  width: min(680px, calc(100vw - 320px));
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 28px rgba(24, 34, 43, 0.16);
}

.product-suggestions.open {
  display: block;
}

.product-count {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--sub);
  background: #f8fafb;
  font-size: 12px;
  font-weight: 800;
}

.product-option {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 6px 12px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 12px;
  text-align: left;
}

.product-option:last-child {
  border-bottom: 0;
}

.product-option:hover {
  background: #edf7fb;
}

.product-option strong {
  font-size: 16px;
}

.product-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  color: #24313b;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.product-option em {
  color: var(--sub);
  font-size: 13px;
  font-style: normal;
}

.product-empty {
  padding: 12px;
  color: var(--sub);
  text-align: center;
}

.primary {
  margin: 4px 16px 0;
  width: calc(100% - 32px);
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
  font-weight: 800;
}

.primary:hover {
  background: var(--blue-dark);
}

.icon-btn {
  width: 40px;
  min-height: 34px;
  padding: 0;
  font-size: 20px;
  font-weight: 700;
}

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

.ghost {
  background: #fff;
}

.list {
  display: grid;
  gap: 0;
}

.list.compact {
  padding: 0 16px 16px;
}

.card {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.card:last-child {
  border-bottom: 0;
  border-radius: 0 0 8px 8px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.card strong {
  font-size: 15px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--sub);
  font-size: 13px;
}

.items {
  margin-top: 8px;
  color: #2d3842;
  font-size: 13px;
}

.warehouse-fields {
  display: grid;
  grid-template-columns: minmax(150px, 1.1fr) minmax(90px, 0.6fr) minmax(90px, 0.6fr) minmax(220px, 1.5fr);
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.warehouse-fields label {
  display: grid;
  gap: 6px;
}

.warehouse-fields span {
  color: var(--sub);
  font-size: 12px;
  font-weight: 800;
}

.warehouse-table-wrap {
  max-width: 100%;
  overflow: auto;
  padding-bottom: 72px;
}

.warehouse-bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f8fbfc;
}

.warehouse-bulk-bar strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  height: 32px;
  color: var(--ink);
  white-space: nowrap;
}

.warehouse-bulk-fields {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.warehouse-file-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.warehouse-bulk-bar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  height: 34px;
}

.warehouse-bulk-bar label span {
  color: var(--sub);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.warehouse-bulk-bar input,
.warehouse-bulk-bar select {
  min-height: 32px;
  padding: 6px 8px;
}

.warehouse-bulk-bar select {
  width: 132px;
}

.warehouse-bulk-bar input {
  width: 96px;
}

.warehouse-bulk-bar button {
  min-height: 32px;
  padding: 5px 12px;
  white-space: nowrap;
}

.warehouse-table {
  min-width: 1640px;
}

.warehouse-table th {
  vertical-align: middle;
}

.warehouse-table td {
  vertical-align: middle;
}

.warehouse-table th,
.warehouse-table td {
  height: 42px;
}

.warehouse-table th,
.warehouse-table td {
  text-align: left;
}

.warehouse-table th:nth-child(1),
.warehouse-table td:nth-child(1) {
  width: 48px;
  text-align: center;
}

.warehouse-table th:nth-child(2),
.warehouse-table td:nth-child(2) {
  width: 96px;
  text-align: center;
}

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

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

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

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

.warehouse-table th:nth-child(7),
.warehouse-table .warehouse-items-cell {
  width: 420px;
  min-width: 420px;
  padding: 0;
}

.warehouse-table th:nth-child(8) {
  width: 72px;
  text-align: right;
}

.warehouse-table .warehouse-items-cell {
  text-align: left;
}

.warehouse-table th:nth-child(9),
.warehouse-table td:nth-child(9) {
  width: 520px;
}

.warehouse-table th:nth-child(10),
.warehouse-table td:nth-child(10) {
  width: 220px;
  min-width: 220px;
  text-align: center;
}

.warehouse-check-col {
  text-align: center;
  vertical-align: middle;
}

.warehouse-check-col input {
  width: 18px;
  min-height: 18px;
  padding: 0;
}

.warehouse-order-start td {
  border-top: 2px solid var(--line-strong);
}

.warehouse-table td {
  background: #fff;
}

.warehouse-system-cell,
.warehouse-status-cell,
.warehouse-action-cell {
  vertical-align: middle;
}

.warehouse-status-cell,
.warehouse-system-cell {
  text-align: center;
}

.waybill-status {
  display: block;
  width: fit-content;
  margin: 5px auto 0;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--amber);
  background: #fff5e8;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.waybill-status.imported {
  color: var(--green);
  background: #e8f6ef;
}

.waybill-status.multi {
  color: var(--blue);
  background: #eaf6fb;
}

.tracking-inline {
  display: grid;
  gap: 2px;
  margin-top: 5px;
  color: var(--sub);
  font-size: 12px;
  line-height: 1.25;
}

.tracking-inline span,
.tracking-inline small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-tracking {
  justify-items: start;
  margin-top: 0;
}

.record-tracking .waybill-status {
  margin: 2px 0 0;
}

.warehouse-confirmed-fields {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  color: var(--ink);
}

.warehouse-confirmed-fields span {
  min-width: 70px;
  color: var(--sub);
  font-weight: 800;
}

.warehouse-confirmed-fields strong {
  font-variant-numeric: tabular-nums;
}

.warehouse-confirmed-fields em {
  color: var(--sub);
  font-style: normal;
}

.warehouse-table th:last-child,
.warehouse-table .warehouse-action-cell {
  position: sticky;
  right: 0;
  z-index: 8;
  box-shadow: -8px 0 14px rgba(24, 34, 43, 0.08);
}

.warehouse-table th:last-child {
  z-index: 5;
  background: #edf3f6;
}

.warehouse-table .warehouse-action-cell {
  background: #fff;
  overflow: visible;
}

.warehouse-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  min-height: 38px;
  border-bottom: 1px solid var(--line);
}

.warehouse-item-row:last-child {
  border-bottom: 0;
}

.warehouse-item-name,
.warehouse-item-qty {
  display: flex;
  align-items: center;
  padding: 9px 10px;
}

.warehouse-item-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.warehouse-item-qty {
  justify-content: flex-end;
  text-align: right;
  border-left: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.warehouse-table .warehouse-fields.compact {
  grid-template-columns: 130px 72px 72px minmax(160px, 1fr);
  gap: 8px;
  min-width: 480px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.warehouse-table .warehouse-fields.compact label {
  gap: 4px;
}

.warehouse-table .warehouse-fields.compact input,
.warehouse-table .warehouse-fields.compact select {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 13px;
}

.warehouse-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-width: 260px;
}

.warehouse-actions button {
  min-height: 32px;
  padding: 6px 10px;
  white-space: nowrap;
}

.action-overflow {
  position: relative;
  z-index: 20;
}

.action-overflow-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--control-radius);
  color: var(--ink);
  background: #fff;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.action-overflow.open .action-overflow-trigger {
  border-color: var(--blue);
  color: var(--blue-dark);
  background: #eef8fb;
}

.action-overflow-menu {
  position: fixed;
  top: var(--action-menu-top, 0);
  left: var(--action-menu-left, 0);
  z-index: 200;
  display: grid;
  gap: 6px;
  min-width: 128px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
}

.action-overflow-menu button {
  justify-content: center;
  width: 100%;
}

.action-overflow.open .action-overflow-menu,
.action-overflow-menu.open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.box-rule-case {
  width: 96px;
}

.box-rule-tail {
  min-width: 150px;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--amber);
  background: #fff5e8;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.confirmed {
  color: var(--green);
  background: #e8f6ef;
}

.pill.imported {
  color: var(--green);
  background: #e8f6ef;
}

.pill.shipped {
  color: #0f6c54;
  background: #dff5ec;
}

.pill.exported {
  color: var(--blue);
  background: #eaf6fb;
}

.pill.cancelled {
  color: var(--red);
  background: #fff0ee;
}

.compact-pill {
  min-height: 20px;
  padding: 2px 6px;
  font-size: 11px;
}

.search {
  width: calc(100% - 32px);
  margin: 0 16px 12px;
}

.panel-search {
  max-width: 420px;
}

.product-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.product-toolbar .panel-search {
  flex: 1 1 320px;
  max-width: 520px;
}

.product-toolbar select {
  width: 180px;
}

.product-toolbar #product-status-filter {
  width: 140px;
}

.table-wrap {
  overflow: auto;
}

.product-table {
  min-width: 1540px;
}

.product-table th,
.product-table td {
  vertical-align: middle;
}

.product-table td {
  height: 52px;
}

.product-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin: 2px 4px 2px 0;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  color: var(--blue-dark);
  background: #eef8fb;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.product-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}

.product-actions button {
  min-height: 32px;
  padding: 6px 10px;
}

.compact-input {
  width: 100%;
  min-width: 84px;
  min-height: var(--control-height-sm);
  height: var(--control-height-sm);
  padding: 6px 8px;
  font-size: 14px;
  white-space: nowrap;
}

.number-input {
  max-width: 86px;
  text-align: center;
}

.center-cell {
  text-align: center;
  vertical-align: middle;
}

.multi-check {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 350px;
}

.form-multi-check {
  flex-wrap: wrap;
  min-width: 0;
}

.multi-check label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--control-height-sm);
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--control-radius);
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.multi-check label:has(input:checked) {
  border-color: var(--blue);
  color: var(--blue-dark);
  background: #eef8fb;
}

.product-readonly-grid {
  margin: 16px;
}

.product-flags {
  padding: 0 16px;
}

.drawer-section-title {
  margin: 12px 16px 6px;
  font-size: 14px;
  line-height: 1.2;
}

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  position: sticky;
  top: 0;
  background: #edf3f6;
  font-weight: 800;
  white-space: nowrap;
}

th:nth-child(1),
td:nth-child(1),
th:nth-child(3),
td:nth-child(3),
th:nth-child(5),
td:nth-child(5),
th:nth-child(6),
td:nth-child(6),
th:nth-child(8),
td:nth-child(8),
th:nth-child(9),
td:nth-child(9) {
  white-space: nowrap;
}

th:nth-child(2),
td:nth-child(2) {
  min-width: 160px;
}

th:nth-child(4),
td:nth-child(4) {
  min-width: 220px;
}

th:nth-child(7),
td:nth-child(7) {
  min-width: 110px;
}

.empty {
  margin: 16px;
  padding: 22px 16px;
  color: var(--sub);
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-2);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 140;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #24313a;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: 0.18s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.inline-save-status {
  margin: 12px 16px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 800;
}

.inline-save-status.saving {
  border-color: #cde0e8;
  color: var(--blue-dark);
  background: #eef8fb;
}

.inline-save-status.success {
  border-color: #b9ead1;
  color: #087443;
  background: #e9f8f0;
}

.inline-save-status.error {
  border-color: #f4b6b6;
  color: #c92a2a;
  background: #fff0f0;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
}

.drawer.open {
  display: block;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 31, 42, 0.32);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(620px, 92vw);
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -18px 0 36px rgba(24, 34, 43, 0.18);
}

#order-detail-drawer .drawer-panel {
  width: min(820px, 96vw);
}

.wide-drawer {
  width: min(980px, 96vw);
}

.drawer-panel form {
  padding-bottom: 18px;
}

.bulk-import-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.bulk-import-body textarea {
  min-height: 180px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

.bulk-preview-wrap table {
  min-width: 900px;
}

tr.import-error td {
  background: #fff3f1;
}

.detail-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.detail-section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.detail-section h3 {
  margin-bottom: 10px;
}

.detail-section p {
  margin-top: 6px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.detail-grid span {
  display: block;
  color: var(--sub);
  font-size: 12px;
  font-weight: 800;
}

.detail-grid strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.tracking-summary-text {
  display: inline;
}

.tracking-actions {
  display: inline-flex;
  gap: 6px;
  margin-left: 8px;
  vertical-align: middle;
}

.tracking-actions button {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.detail-recipient {
  display: grid;
  gap: 8px;
  line-height: 1.55;
}

.detail-recipient span {
  overflow-wrap: anywhere;
}

.detail-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.detail-table th,
.detail-table td {
  white-space: normal;
  overflow-wrap: anywhere;
}

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

.detail-table th:nth-child(3),
.detail-table td:nth-child(3) {
  width: 72px;
  text-align: right;
}

@media (max-width: 1100px) {
  body {
    min-width: 0;
  }

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

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
  }

  .role-switch {
    grid-template-columns: repeat(4, minmax(116px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .session-panel {
    order: 5;
    margin: 12px 0 0;
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .sidebar-language {
    order: 4;
    margin: 12px 0 0;
    max-width: 220px;
  }

  .layout,
  .layout.wide,
  .page-head {
    display: block;
  }

  .page-title {
    display: block;
  }

  .page-head p {
    margin-top: 4px;
    white-space: normal;
  }

  .panel,
  .summary-strip {
    margin-top: 14px;
  }
}

@media (max-width: 720px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    font-size: 15px;
  }

  .app-shell,
  .sidebar,
  main {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  button,
  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  input[type="checkbox"] {
    width: var(--check-size);
    height: var(--check-size);
    min-width: var(--check-size);
    min-height: var(--check-size);
    padding: 0;
  }

  .login-card {
    padding: 22px;
  }

  .sidebar {
    padding: 10px;
  }

  .brand {
    padding: 4px 2px 12px;
  }

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

  .brand h1 {
    font-size: 18px;
  }

  .role-switch {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .role-switch button {
    flex: 0 0 auto;
    width: auto;
    min-width: 96px;
    min-height: 40px;
    padding: 8px 12px;
    text-align: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
  }

  .nav-submenu {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
    margin: 0;
    padding: 0;
    border-left: 0;
  }

  .nav-submenu button {
    width: auto;
    min-width: 90px;
    min-height: 40px;
    justify-content: center;
    text-align: center;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
  }

  .session-panel {
    grid-template-columns: 1fr auto;
    margin-top: 10px;
    padding: 10px;
  }

  .sidebar-language {
    max-width: none;
    margin-top: 10px;
  }

  .language-switch {
    min-height: 40px;
  }

  .language-switch button {
    min-height: 34px;
    font-size: 14px;
  }

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

  .audit-row {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 10px 0;
  }

  main {
    padding: 12px;
  }

  .page-head {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
  }

  .page-title {
    display: grid;
    gap: 4px;
  }

  .page-head h2 {
    font-size: 22px;
  }

  .summary-strip {
    grid-template-columns: repeat(3, 1fr);
    margin-top: 0;
  }

  .summary-strip div {
    min-height: 48px;
    padding: 7px 9px;
  }

  .panel {
    border-radius: 7px;
  }

  .panel-head {
    display: grid;
    gap: 10px;
    min-height: 0;
    padding: 12px;
  }

  .panel-actions {
    justify-content: stretch;
    width: 100%;
  }

  .panel-actions button {
    width: auto;
  }

  .panel-actions .panel-search {
    min-width: 0;
    flex: 1;
  }

  form.panel label,
  .form-group,
  .account-banner {
    margin-right: 12px;
    margin-left: 12px;
  }

  .account-banner {
    min-height: 44px;
    padding: 10px;
  }

  .group-title {
    align-items: center;
  }

  .recipient-picker {
    grid-template-columns: 1fr;
  }

  .recipient-suggestions,
  .product-suggestions {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 12px;
    width: auto;
    max-height: min(56vh, 420px);
    z-index: 80;
  }

  .selected-recipient,
  .preview {
    margin-right: 12px;
    margin-left: 12px;
  }

  .items-head {
    margin: 14px 12px 8px;
  }

  .item-labels {
    display: none;
  }

  .item-row {
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 0 12px 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fbfdfe;
  }

  .item-row .remove-item {
    width: 100%;
  }

  .add-item-bottom {
    width: calc(100% - 24px);
    margin: 0 12px 14px;
    border-color: var(--blue);
    color: var(--blue);
    font-weight: 800;
    background: #f4fbfd;
  }

  .form-actions {
    display: grid;
    gap: 8px;
    margin-right: 12px;
    margin-left: 12px;
  }

  .record-filters,
  .address-toolbar,
  .fee-list-toolbar,
  .fee-report-filters,
  .fee-form,
  .standalone-fee-fields {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .fee-list-toolbar button,
  .fee-report-filters button {
    width: 100%;
  }

  .drawer-fee-form,
  .standalone-fee-fields {
    padding: 0;
  }

  .standalone-fee-fields label:last-child {
    grid-column: auto;
  }

  .settings-grid,
  .settings-form {
    grid-template-columns: 1fr;
  }

  .settings-form {
    padding: 12px;
  }

  .table-wrap {
    margin: 0;
    max-width: calc(100vw - 24px);
  }

  table {
    min-width: 760px;
  }

  .warehouse-table {
    min-width: 1280px;
  }

  .warehouse-bulk-bar {
    display: grid;
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .record-bulk-bar {
    display: grid;
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .record-bulk-bar button {
    width: 100%;
  }

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

  .warehouse-bulk-fields,
  .warehouse-file-actions {
    display: grid;
    grid-template-columns: 1fr;
    margin-left: 0;
  }

  .warehouse-bulk-bar label,
  .warehouse-bulk-bar select,
  .warehouse-bulk-bar input,
  .warehouse-bulk-bar button {
    width: 100%;
  }

  .drawer-panel,
  #order-detail-drawer .drawer-panel,
  .wide-drawer {
    width: 100vw;
    max-width: 100vw;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .two-col {
    grid-template-columns: 1fr;
  }
}
