:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #dce3ea;
  --line-strong: #c7d1dc;
  --text: #1d2733;
  --muted: #667586;
  --blue: #2364aa;
  --blue-deep: #174c84;
  --blue-soft: #e8f1fb;
  --teal: #0f8b8d;
  --green: #16845b;
  --amber: #b96c18;
  --red: #b83d3d;
  --shadow: 0 18px 45px rgba(31, 45, 61, 0.12);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  color: var(--text);
  background: var(--bg);
}

body.auth-loading .app-shell,
body.auth-required .app-shell,
body.authenticated .login-screen {
  display: none;
}

body.auth-loading .login-screen,
body.auth-required .login-screen {
  display: grid;
}

.hidden {
  display: none !important;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 100vh;
}

.login-screen {
  display: none;
  min-height: 100vh;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74) 0%, rgba(244, 246, 248, 0.94) 100%),
    radial-gradient(circle at 20% 20%, #d9e9fb 0%, transparent 32%),
    radial-gradient(circle at 80% 10%, #e3f4f0 0%, transparent 28%);
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(420px, calc(100vw - 48px));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px;
  background: #ffffff;
  box-shadow: var(--shadow);
  align-self: center;
}

.login-card h1 {
  margin: 6px 0 0;
  color: #172333;
  font-size: 26px;
}

.login-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.login-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 800;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.form-error {
  margin: 16px 0 0;
  border: 1px solid #f2b8b5;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff4f3;
  color: var(--red);
  font-size: 13px;
  line-height: 1.5;
}

.login-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.login-footer {
  padding-top: 24px;
  color: #8a96a5;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.login-footer a {
  color: inherit;
  text-decoration: none;
}

.login-footer a:hover {
  color: var(--blue);
  text-decoration: underline;
}

.sidebar {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #244f91;
  color: #eef5ff;
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 20px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  color: var(--blue);
  font-weight: 800;
}

.brand span,
.eyebrow,
.hint {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.brand span {
  color: #b9c9dd;
  margin-top: 3px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  color: #dce8f8;
  background: transparent;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: #173e76;
  color: #fff;
}

.nav-list > .nav-item {
  font-weight: 700;
}

.nav-group {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.nav-group span {
  padding: 0 12px 4px;
  color: #aecaec;
  font-size: 12px;
  font-weight: 700;
}

.nav-group .nav-item {
  min-height: 38px;
  color: #cbdcf0;
  font-size: 13px;
}

.user-panel {
  display: grid;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding: 14px 8px 0;
}

.user-panel strong,
.user-panel span {
  display: block;
}

.user-panel strong {
  color: #ffffff;
  font-size: 14px;
}

.user-panel span {
  margin-top: 3px;
  color: #b9c9dd;
  font-size: 12px;
}

.user-panel .ghost-button {
  width: 100%;
  border-color: rgba(255, 255, 255, 0.24);
  color: #eef5ff;
}

.user-panel-actions {
  display: grid;
  gap: 8px;
}

.workspace {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 22px 28px 34px;
}

.view-section {
  display: none;
  align-content: start;
  gap: 16px;
}

.view-section.active-view {
  display: grid;
}

.topbar,
.controls-panel,
.modal-header,
.mail-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1,
.modal-header h2 {
  margin: 3px 0 0;
  font-size: 24px;
  line-height: 1.2;
}

.modal-header h2 {
  font-size: 20px;
}

.modal-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.top-actions,
.batch-actions,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.batch-actions {
  flex-wrap: wrap;
}

.confirm-body .modal-actions {
  width: 100%;
  flex-wrap: wrap;
}

.action-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bill-type-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.bill-type-filter > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  word-break: keep-all;
}

.filter-chip {
  min-width: 48px;
  min-height: 30px;
  border: 1px solid #c9d8ea;
  border-radius: 6px;
  padding: 0 10px;
  background: #edf4fb;
  color: #5b6f86;
  font-weight: 600;
  white-space: nowrap;
  word-break: keep-all;
}

.filter-chip:hover {
  border-color: #8fb1d8;
  color: var(--blue);
}

.bill-type-filter .filter-chip.active,
.bill-type-filter .filter-chip[aria-pressed="true"] {
  border-color: var(--blue-deep);
  background: var(--blue-deep);
  color: #fff;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 600;
  white-space: nowrap;
  word-break: keep-all;
}

.primary-button {
  background: var(--blue);
  color: #fff;
}

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

.secondary-button {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
}

.ghost-button {
  background: transparent;
  border-color: var(--line);
  color: var(--blue);
}

.icon-button {
  width: 34px;
  padding: 0;
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--muted);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.summary-strip div,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-strip div {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
}

.summary-strip span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.summary-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.summary-select select {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.summary-strip strong {
  display: block;
  margin-top: 0;
  font-size: 22px;
  line-height: 1;
}

.controls-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  padding: 14px 16px;
}

.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.bill-filters {
  flex-wrap: nowrap;
}

.batch-actions {
  flex-wrap: nowrap;
  align-items: end;
  gap: 8px;
}

.batch-actions .secondary-button,
.batch-actions .primary-button {
  padding: 0 12px;
  white-space: nowrap;
}

.search-field,
.date-field,
.date-range-field,
.select-field,
.form-grid label,
.carrier-fee-form label,
.container-type-form label,
.template-editor label,
.mail-tools label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  background: #fff;
  outline: none;
}

textarea {
  padding: 10px;
  line-height: 1.6;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 100, 170, 0.13);
}

input[readonly] {
  color: var(--muted);
  background: var(--surface-soft);
}

.search-field input {
  width: 137px;
}

.date-field input {
  width: 142px;
}

.date-range-field {
  position: relative;
  width: 102px;
}

.date-range-control {
  display: flex;
  min-height: 36px;
  align-items: stretch;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}

.date-range-display {
  flex: 1;
  min-height: 34px;
  border: 0;
  border-radius: 0;
  padding: 0 10px;
  background: #fff;
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.date-range-display.has-value {
  color: var(--text);
}

.date-range-clear {
  display: grid;
  width: 32px;
  min-height: 34px;
  place-items: center;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  padding: 0;
  background: #fff;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  visibility: hidden;
}

.date-range-clear.visible {
  visibility: visible;
}

.date-range-control:focus-within,
.date-range-field:has(.date-range-popover.open) .date-range-control {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 100, 170, 0.13);
}

.date-range-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 12;
  display: none;
  width: min(650px, calc(100vw - 48px));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  background: #fff;
  box-shadow: var(--shadow);
}

.date-range-popover.open {
  display: block;
}

.date-range-calendar {
  width: 100%;
  color: var(--text);
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.calendar-toolbar-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.calendar-nav-button {
  width: 32px;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.calendar-nav-button:hover {
  background: var(--surface-soft);
  color: var(--blue);
}

.calendar-months {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.calendar-month {
  min-width: 0;
  padding: 12px 14px 10px;
}

.calendar-month + .calendar-month {
  border-left: 1px solid var(--line);
}

.calendar-month-title {
  display: block;
  margin-bottom: 10px;
  color: #2f3b49;
  font-size: 17px;
  text-align: center;
}

.calendar-weekdays,
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekday {
  padding: 5px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.calendar-day {
  position: relative;
  min-width: 0;
  min-height: 34px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: #4d5968;
  font-weight: 500;
}

.calendar-day:hover {
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue-deep);
}

.calendar-day.outside {
  color: #bdc5ce;
}

.calendar-day.in-range {
  background: #edf5ff;
}

.calendar-day.range-start,
.calendar-day.range-end {
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.calendar-day.today:not(.range-start):not(.range-end) {
  box-shadow: inset 0 0 0 1px var(--blue);
  border-radius: 6px;
  color: var(--blue);
}

.calendar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 10px 12px;
}

.calendar-selection {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.calendar-footer-button {
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.calendar-footer-button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.bill-filters .search-field input {
  width: 117px;
}

.bill-filters .date-range-field {
  width: 90px;
}

.table-panel {
  overflow: hidden;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 266px);
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  border-top: 1px solid var(--line);
  padding: 12px 4px 0;
  color: #5c6775;
}

.pagination-total {
  flex: 1;
  min-width: 180px;
  font-size: 14px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.page-button {
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: #4d5968;
  font-weight: 600;
}

.page-button.active {
  border-color: var(--blue);
  color: var(--blue);
  background: #f5f9ff;
}

.page-button:disabled {
  color: #bcc5d0;
  background: #f7f9fb;
  cursor: not-allowed;
}

.page-ellipsis {
  min-width: 26px;
  text-align: center;
  color: #a1aab6;
  font-weight: 800;
}

.page-size-select,
.page-jumper {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
}

.page-size-select {
  padding: 0 8px;
}

.page-jump-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #5c6775;
}

.page-jumper {
  width: 68px;
  padding: 0 8px;
}

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

th,
td {
  height: 48px;
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: #455568;
  font-weight: 700;
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: inherit;
}

th:nth-child(2),
td:nth-child(2) {
  position: sticky;
  left: 42px;
  z-index: 2;
  background: inherit;
}

th:last-child,
td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  background: inherit;
  box-shadow: -8px 0 14px rgba(31, 45, 61, 0.04);
}

th:first-child,
th:nth-child(2),
th:last-child {
  z-index: 3;
  background: var(--surface-soft);
}

td:first-child,
td:nth-child(2),
td:last-child {
  background: #fff;
}

tbody tr:hover td:first-child,
tbody tr:hover td:nth-child(2),
tbody tr:hover td:last-child {
  background: #f7fbff;
}

tbody tr:hover {
  background: #f7fbff;
}

.cancelled-row {
  color: #8a95a3;
  background: #fafbfc;
}

.cancelled-row td {
  color: #8a95a3;
  background: #fafbfc;
}

.cancelled-row:hover {
  background: #f4f6f8;
}

.cancelled-row:hover td:first-child,
.cancelled-row:hover td:nth-child(2),
.cancelled-row:hover td:last-child {
  background: #f4f6f8;
}

.empty-row td {
  height: 180px;
  text-align: center;
  white-space: normal;
}

.empty-state {
  display: grid;
  gap: 8px;
  place-items: center;
  color: var(--muted);
}

.empty-state strong {
  color: #2f3b4a;
  font-size: 16px;
}

.empty-state span {
  font-size: 13px;
}

.check-cell {
  width: 42px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-width: 66px;
  height: 24px;
  justify-content: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.pending {
  background: #fff4df;
  color: var(--amber);
}

.status-pill.done {
  background: #e7f6ef;
  color: var(--green);
}

.status-pill.eir-completed {
  background: #e4f7f5;
  color: #087c72;
}

.status-pill.cancelled {
  background: #eef1f5;
  color: #667586;
}

.status-pill.processing {
  background: #e9f3ff;
  color: var(--blue);
}

.status-pill.failed {
  background: #fff0ef;
  color: var(--red);
}

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

.eir-action {
  font-weight: 800;
}

.eir-progress-dialog {
  width: min(560px, calc(100vw - 32px));
}

.eir-progress-body {
  padding: 22px 24px 24px;
}

.eir-progress-list {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  padding: 0;
  list-style: none;
}

.eir-progress-list li {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f5f7fa;
  color: #667586;
  font-size: 13px;
}

.eir-progress-list li.active {
  background: #e9f3ff;
  color: var(--blue);
  font-weight: 700;
}

.eir-progress-list li.done {
  background: #e7f6ef;
  color: var(--green);
}

.eir-progress-list li.failed {
  background: #fff0ef;
  color: var(--red);
}

.eir-progress-note {
  min-height: 42px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.eir-progress-note.error {
  color: var(--red);
}

.link-button {
  border: 0;
  padding: 0;
  color: var(--blue);
  background: transparent;
}

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

.disabled-link {
  color: #9aa6b2;
  cursor: not-allowed;
}

.modal {
  width: min(940px, calc(100vw - 48px));
  max-height: calc(100vh - 16px);
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: var(--shadow);
}

#orderModal {
  width: min(1080px, calc(100vw - 48px));
}

#carrierFeeModal {
  width: min(1180px, calc(100vw - 48px));
}

.detail-modal {
  width: min(1120px, calc(100vw - 48px));
}

.confirm-modal {
  width: min(430px, calc(100vw - 48px));
  max-height: none;
  overflow: visible;
}

.danger-button {
  background: var(--red);
}

.danger-button:hover {
  background: #982f2f;
}

.danger-text-button {
  border-color: #f0c7c7;
  color: var(--red);
}

.confirm-body {
  display: grid;
  gap: 18px;
  box-sizing: border-box;
  width: auto;
  min-width: 0;
  max-height: none;
  overflow: visible;
}

.confirm-body h2 {
  margin: 4px 0 8px;
  font-size: 20px;
}

.confirm-body p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.confirm-modal::backdrop {
  background: rgba(12, 20, 31, 0.42);
}

.modal::backdrop {
  background: rgba(12, 20, 31, 0.38);
}

.modal-body {
  max-height: calc(100vh - 16px);
  overflow: auto;
  padding: 22px;
}

.order-modal-body {
  padding: 16px;
}

.wide-modal {
  width: 100%;
}

.small-modal {
  width: min(560px, calc(100vw - 48px));
}

.settings-modal-body {
  background: #f7f9fc;
}

.required-label::after {
  content: " *";
  color: var(--red);
  font-weight: 800;
}

.form-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.order-modal-body .form-sections {
  gap: 10px;
  margin-top: 12px;
}

.form-section-wide {
  grid-column: 1 / -1;
}

.driver-section {
  background: #fbfcfd;
}

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

.order-modal-body .form-section {
  padding: 9px 10px;
}

.form-section h3 {
  margin: 0 0 12px;
  color: #334155;
  font-size: 15px;
}

.order-modal-body .form-section h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

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

.section-title-row h3 {
  margin: 0;
}

.image-drop-zone {
  display: grid;
  gap: 6px;
  min-height: 92px;
  place-content: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  text-align: center;
}

.order-modal-body .image-drop-zone {
  min-height: 48px;
}

.image-drop-zone:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 100, 170, 0.13);
  outline: none;
}

.image-drop-zone strong {
  color: var(--text);
}

.image-drop-zone span {
  font-size: 12px;
}

.image-preview-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.order-modal-body .image-preview-list {
  gap: 8px;
  margin-top: 8px;
}

.image-preview-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.image-preview-item img {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 6px;
}

.order-modal-body .image-preview-item {
  grid-template-columns: 56px minmax(0, 1fr);
  padding: 6px;
}

.order-modal-body .image-preview-item img {
  width: 56px;
  height: 40px;
}

.image-preview-item span {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.single-column {
  grid-template-columns: 1fr;
  margin-top: 18px;
}

.order-modal-body .form-grid {
  gap: 10px;
}

.order-modal-body input,
.order-modal-body select {
  min-height: 32px;
}

.order-modal-body .paired-section .form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.paired-section .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bill-form-grid {
  grid-template-columns: 1fr;
  margin-top: 16px;
}

.paste-recognition,
.settings-section {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.paste-recognition h3,
.settings-section h3 {
  margin: 0;
  color: #334155;
  font-size: 15px;
}

.settings-modal-body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: min(760px, calc(100vh - 16px));
  overflow: hidden;
  padding: 0;
  background: #fff;
}

.settings-modal-body > .modal-header {
  margin: 0;
  padding: 18px 22px;
  background: #fff;
}

.settings-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 0;
  background: #f7f9fc;
}

.settings-nav {
  display: grid;
  align-content: start;
  gap: 6px;
  border-right: 1px solid #dce5ef;
  padding: 18px 14px;
  background: #f2f6fb;
}

.settings-nav-label {
  margin: 0 10px 6px;
  color: #8794a5;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.settings-nav-item {
  display: grid;
  width: 100%;
  min-height: 60px;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  background: transparent;
  color: #435267;
  text-align: left;
}

.settings-nav-item strong {
  font-size: 14px;
}

.settings-nav-item span {
  color: #7a889a;
  font-size: 11px;
  font-weight: 500;
}

.settings-nav-item:hover {
  border-color: #d6e1ee;
  background: rgba(255, 255, 255, 0.72);
}

.settings-nav-item.active {
  border-color: #c7d9ee;
  background: #fff;
  color: var(--blue-deep);
  box-shadow: 0 4px 14px rgba(31, 72, 119, 0.08);
}

.settings-nav-item.active span {
  color: #607c9d;
}

.settings-content {
  min-height: 0;
  overflow: auto;
  padding: 22px;
}

.settings-panel {
  display: none;
  align-content: start;
  gap: 14px;
  max-width: 920px;
  margin: 0 auto;
}

.settings-panel.active {
  display: grid;
}

.settings-panel-header {
  display: flex;
  min-height: 66px;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid #dce5ef;
  padding: 0 2px 16px;
}

.settings-panel-header h3 {
  margin: 2px 0 5px;
  color: #263548;
  font-size: 22px;
}

.settings-panel-header p:not(.settings-kicker) {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.settings-kicker {
  margin: 0;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.settings-status,
.settings-count {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border: 1px solid #cfe4d8;
  border-radius: 999px;
  padding: 0 10px;
  background: #f0faf4;
  color: #2f7b51;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.settings-count {
  border-color: #d9e3ef;
  background: #f5f8fc;
  color: #617085;
}

.settings-modal-body .settings-section {
  margin-top: 0;
  border-color: #d9e2ec;
  padding: 16px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(35, 54, 78, 0.035);
}

.settings-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.settings-heading h4,
.user-create-form h4 {
  margin: 0;
  color: #334155;
  font-size: 15px;
}

.settings-heading .hint,
.user-create-form .hint {
  margin-top: 4px;
}

.account-section {
  max-width: 720px;
  border-left: 4px solid var(--blue);
}

.account-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.settings-two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.data-safety-section {
  border-left: 4px solid #d99a2b !important;
}

.paste-recognition textarea {
  min-height: 120px;
  resize: vertical;
}

.bill-container-group {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.square-button {
  display: inline-grid;
  width: 30px;
  min-height: 30px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--blue);
  font-weight: 800;
}

.container-input-list {
  display: grid;
  gap: 8px;
}

.container-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.modal-actions {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.order-modal-body .modal-actions {
  margin-top: 10px;
  padding-top: 10px;
}

.modal-customer-field {
  display: grid;
  width: 154px;
  min-width: 154px;
  margin-right: auto;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}

.modal-customer-field select {
  min-height: 36px;
  height: 36px;
}

#orderModal .modal-customer-field select {
  min-height: 32px;
  height: 32px;
}

.container-type-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.container-type-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px 0 10px;
  background: #fff;
  color: #334155;
  font-weight: 700;
}

.container-type-item button {
  min-height: 24px;
  border: 0;
  padding: 0 2px;
  color: var(--red);
  background: transparent;
  font-weight: 800;
}

.container-type-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

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

.backup-file-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.wide {
  grid-column: 1 / -1;
}

.template-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.template-list {
  display: grid;
  align-content: start;
  gap: 8px;
  border-right: 1px solid var(--line);
  padding-right: 14px;
}

.template-tab {
  display: grid;
  gap: 3px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  text-align: left;
  background: var(--surface);
}

.template-tab span {
  color: var(--muted);
  font-size: 12px;
}

.template-tab.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue-deep);
}

.template-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.hint {
  grid-column: 1 / -1;
  margin: 0;
  line-height: 1.6;
}

.columns-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.columns-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
}

.carrier-fee-list {
  display: grid;
  gap: 10px;
  margin: 20px 0 14px;
}

.user-management {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 18px;
}

.user-list-panel,
.user-create-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.user-list-panel h3,
.user-create-form h3 {
  margin: 0;
  color: #334155;
  font-size: 15px;
}

.user-create-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 12px;
}

.user-create-form > div {
  grid-column: 1 / -1;
}

.user-create-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.user-table-wrap {
  overflow: auto;
  margin-top: 12px;
}

.user-table {
  min-width: 720px;
}

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

.role-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--blue-soft);
  color: var(--blue-deep);
  font-size: 12px;
  font-weight: 700;
}

.role-pill.user {
  background: #eef1f5;
  color: #586575;
}

.role-pill.superadmin {
  background: #fff2db;
  color: #8a4a00;
}

.recycle-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

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

.recycle-sections h3 {
  margin: 0 0 12px;
  color: #334155;
  font-size: 15px;
}

.recycle-list {
  display: grid;
  gap: 10px;
}

.recycle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.recycle-item strong,
.recycle-item span {
  display: block;
}

.recycle-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.carrier-fee-row,
.carrier-fee-form {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(120px, 0.7fr) auto;
  gap: 10px;
  align-items: end;
}

.carrier-fee-row {
  align-items: center;
}

.customer-management,
.customer-list {
  display: grid;
  gap: 10px;
}

.customer-row {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px 6px 12px;
  background: #fff;
}

.customer-create-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.mail-tools {
  align-items: end;
  margin: 18px 0 12px;
}

.mail-tools label {
  flex: 1;
}

.mail-preview {
  width: 100%;
  min-height: 360px;
}

.mail-preview.hidden,
.mail-html-preview.hidden {
  display: none;
}

.mail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.mail-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  background: #fff;
  color: #526172;
  font-size: 12px;
}

.mail-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.attachment-chip {
  display: inline-grid;
  gap: 2px;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 6px 12px;
  background: #fff;
  color: var(--blue-deep);
  text-align: left;
}

.attachment-chip span {
  font-weight: 800;
}

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

.mail-html-preview {
  min-height: 360px;
  max-height: 56vh;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
  color: #1d2733;
  line-height: 1.65;
}

.attachment-table-wrap {
  overflow: auto;
  margin-top: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.attachment-preview-table {
  min-width: 980px;
  font-family: "SimSun", "宋体", serif;
  font-size: 12px;
  border-collapse: collapse;
}

.attachment-preview-table th,
.attachment-preview-table td {
  height: 28px;
  border: 1px solid #2d2d2d;
  padding: 0 8px;
  text-align: center;
}

.attachment-preview-table th {
  position: static;
  background: #ffff00;
  color: #000;
  font-weight: 400;
}

.attachment-preview-table td:first-child,
.attachment-preview-table td:nth-child(10) {
  text-align: left;
}

.send-log-table-wrap {
  overflow: auto;
  margin-top: 18px;
}

.send-log-table {
  min-width: 980px;
}

.send-log-table th,
.send-log-table td {
  height: 46px;
}

#sendLogsModal .pagination-bar {
  padding-right: 0;
  padding-left: 0;
}

.export-range-modal {
  width: min(720px, calc(100vw - 48px));
}

.export-range-modal-body {
  width: 100%;
}

.export-range-hint {
  margin: 16px 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.export-date-range-calendar {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.export-range-modal [data-calendar-apply] {
  display: none;
}

.detail-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 10px;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.detail-group {
  border: 1px solid #d7e0ea;
  border-radius: 8px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f9fbfd 100%);
}

.detail-group h3 {
  margin: 0 0 8px;
  color: #334155;
  font-size: 13px;
}

.detail-group-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}

.detail-remark-group {
  grid-column: 1 / -1;
}

.detail-remark-input {
  width: 100%;
  min-height: 34px;
}

.detail-field {
  display: grid;
  gap: 2px;
  min-height: 44px;
  align-content: start;
  border-bottom: 1px solid #edf1f5;
  padding-bottom: 6px;
}

.detail-field span {
  color: var(--muted);
  font-size: 12px;
}

.detail-field strong {
  overflow-wrap: anywhere;
  color: #253244;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.detail-copy-source {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toast {
  position: fixed;
  top: 22px;
  left: 50%;
  z-index: 20;
  transform: translate(-50%, -12px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: #ffffff;
  color: #253244;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 760px) {
  body {
    min-width: 0;
    background: #eef2f6;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    align-content: start;
    min-height: 100dvh;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    align-self: start;
    grid-template-rows: auto auto;
    align-content: start;
    gap: 12px;
    padding: 14px 12px 12px;
    background: #244f91;
  }

  .workspace {
    padding: 8px;
    gap: 8px;
  }

  .brand {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    padding: 0;
  }

  .brand-mark {
    display: none;
  }

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

  .brand span {
    display: none;
  }

  .nav-list {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    height: 30px;
    max-height: 30px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-list > .nav-item,
  .nav-group .nav-item {
    flex: 0 0 auto;
    width: auto;
    height: 30px;
    min-height: 30px;
    max-height: 30px;
    border-radius: 12px;
    padding: 0 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #eaf2ff;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
  }

  .nav-item.active,
  .nav-item:hover {
    background: #ffffff;
    color: var(--blue);
  }

  .nav-group {
    display: contents;
  }

  .mobile-hidden-nav {
    display: none !important;
  }

  .nav-group span,
  .user-panel,
  #ordersView > .summary-strip,
  #billsView > .summary-strip {
    display: none !important;
  }

  .topbar,
  .controls-panel,
  .filters,
  .batch-actions,
  .template-layout,
  .template-editor,
  .user-management,
  .settings-two-column,
  .form-grid,
  .form-sections,
  .detail-group-grid,
  .detail-card,
  .image-preview-list,
  .carrier-fee-row,
  .carrier-fee-form,
  .container-type-form,
  .summary-strip {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions,
  .batch-actions {
    justify-content: stretch;
  }

  .action-group {
    display: grid;
    grid-template-columns: 1fr;
  }

  .pagination-bar,
  .pagination-controls {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .pagination-total {
    min-width: 0;
  }

  .page-jump-group {
    justify-content: space-between;
  }

  .page-jumper,
  .page-size-select {
    width: 100%;
  }

  .top-actions button,
  .batch-actions button {
    width: 100%;
  }

  .search-field input,
  .date-field input,
  .date-range-field,
  .date-range-popover {
    width: 100%;
  }

  .calendar-months {
    grid-template-columns: 1fr;
  }

  .calendar-month + .calendar-month {
    display: none;
  }

  .calendar-toolbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .calendar-nav-button[data-calendar-shift="-12"],
  .calendar-nav-button[data-calendar-shift="12"] {
    display: none;
  }

  .calendar-selection {
    grid-column: 1 / -1;
  }

  .calendar-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .controls-panel {
    align-items: stretch;
    overflow: hidden;
    padding: 8px;
  }

  #ordersView .controls-panel,
  #billsView .controls-panel {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 6px;
  }

  #ordersView .filters,
  #ordersView .batch-actions,
  #ordersView .action-group,
  #billsView .batch-actions,
  #billsView .action-group {
    display: contents;
  }

  .filters,
  .batch-actions {
    gap: 6px;
  }

  #ordersView .search-field {
    order: 1;
    grid-column: 1 / 8;
    min-width: 0;
  }

  #ordersView .search-field span,
  #ordersView .select-field span,
  #billsView .bill-filters .search-field span {
    display: none;
  }

  #ordersView .select-field {
    order: 2;
    grid-column: 8 / 13;
    min-width: 0;
  }

  #ordersView #openOrder {
    order: 3;
    grid-column: 1 / 5;
  }

  #ordersView #markDone {
    order: 4;
    grid-column: 5 / 9;
  }

  #ordersView #composeMail {
    order: 5;
    grid-column: 9 / 13;
  }

  #ordersView [data-date-range="orders"],
  #ordersView #markPending,
  #ordersView #openColumns,
  #ordersView #exportTable,
  #billsView [data-date-range="bills"],
  #billsView #markBillsPending,
  #billsView #openBillColumns,
  #billsView #exportBillTable {
    display: none !important;
  }

  .bill-filters {
    display: contents;
  }

  #billsView #openImportBill {
    order: 1;
    grid-column: 1 / 7;
  }

  #billsView #openExportBill {
    order: 2;
    grid-column: 7 / 13;
  }

  .bill-type-filter {
    order: 3;
    grid-column: 1 / 13;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    min-width: 0;
  }

  .bill-type-filter > span {
    font-size: 11px;
  }

  .bill-type-filter .filter-chip {
    width: 100%;
    min-height: 30px;
    padding: 0 5px;
    font-size: 11px;
  }

  .bill-filters .search-field {
    order: 4;
    grid-column: 1 / 5;
    min-width: 0;
  }

  #billsView #markBillsDone {
    order: 5;
    grid-column: 5 / 9;
  }

  #billsView #mailBills {
    order: 6;
    grid-column: 9 / 13;
  }

  .action-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .batch-actions .action-group:last-child {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    min-width: 0;
    min-height: 30px;
    border-radius: 5px;
    padding: 0 4px;
    font-size: 11px;
    line-height: 1.15;
  }

  input,
  select,
  textarea {
    min-width: 0;
    min-height: 30px;
    padding: 0 7px;
    font-size: 12px;
  }

  #ordersView .search-field input,
  #ordersView .select-field select,
  #billsView .search-field input {
    width: 100%;
  }

  .table-panel {
    overflow: hidden;
    border: 1px solid var(--line);
    background: #fff;
  }

  .table-wrap {
    overflow-x: auto;
    overflow-y: visible;
    max-height: none;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 620px;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 11px;
    line-height: 1.15;
  }

  thead {
    display: table-header-group;
  }

  tbody {
    display: table-row-group;
  }

  tbody tr {
    display: table-row;
    height: 34px;
    border: 0;
    background: #fff;
    box-shadow: none;
  }

  td,
  th:first-child,
  td:first-child,
  th:nth-child(2),
  td:nth-child(2),
  th:last-child,
  td:last-child {
    position: static;
    left: auto;
    right: auto;
    z-index: auto;
    box-shadow: none;
  }

  th,
  td {
    display: table-cell;
    height: 34px;
    max-height: 34px;
    min-height: 0;
    border-bottom: 1px solid #edf1f5;
    padding: 0 6px;
    white-space: nowrap;
    word-break: keep-all;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #fff;
    vertical-align: middle;
  }

  th {
    height: 34px;
    background: #f6f9fc;
    color: #4d5c6f;
    font-size: 11px;
  }

  td::before {
    content: none;
  }

  td:last-child {
    border-bottom: 1px solid #edf1f5;
  }

  td.check-cell {
    background: #f8fbff;
  }

  .check-cell {
    width: 42px;
    text-align: center;
  }

  .check-cell input {
    width: 18px;
    height: 18px;
  }

  .status-pill {
    min-height: 22px;
    padding: 0 7px;
    font-size: 11px;
  }

  #ordersView table {
    min-width: 470px;
  }

  #ordersView th:nth-child(2),
  #ordersView td:nth-child(2) {
    width: 112px;
  }

  #ordersView th:nth-child(3),
  #ordersView td:nth-child(3) {
    width: 74px;
  }

  #ordersView th:last-child,
  #ordersView td:last-child {
    width: 190px;
  }

  #billsView table {
    min-width: 470px;
  }

  #billsView th:nth-child(2),
  #billsView td:nth-child(2) {
    width: 150px;
  }

  #billsView th:nth-child(3),
  #billsView td:nth-child(3) {
    width: 52px;
  }

  #billsView th:nth-child(4),
  #billsView td:nth-child(4) {
    width: 42px;
  }

  #billsView th:nth-child(5),
  #billsView td:nth-child(5) {
    width: 62px;
  }

  #billsView th:last-child,
  #billsView td:last-child {
    width: 160px;
  }

  .row-actions {
    width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 5px;
  }

  .link-button {
    min-height: 26px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 7px;
    background: #fff;
    font-size: 11px;
    font-weight: 700;
  }

  .danger-link {
    border-color: #f0c7c7;
  }

  .pagination-bar {
    margin-top: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px;
    background: #fff;
  }

  .pagination-controls {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .page-button {
    width: 100%;
    min-height: 32px;
  }

  .page-size-select,
  .page-jump-group {
    grid-column: 1 / -1;
  }

  .modal,
  #orderModal,
  #carrierFeeModal,
  .detail-modal,
  .confirm-modal {
    width: 100vw;
    max-width: 100vw;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .modal-body,
  .order-modal-body,
  .small-modal,
  .wide-modal,
  .settings-modal-body {
    width: 100%;
    max-height: 100dvh;
    min-height: 100dvh;
    padding: 14px;
  }

  .modal-header {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: -14px -14px 12px;
    padding: 14px;
    background: #fff;
  }

  #sendLogsModal .modal-header,
  #carrierFeeModal .modal-header {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 10px;
  }

  #sendLogsModal .modal-header .icon-button,
  #carrierFeeModal .modal-header .icon-button {
    order: -1;
    width: 34px;
    min-height: 34px;
  }

  .modal-header h2 {
    font-size: 18px;
  }

  #sendLogsModal .wide-modal,
  #carrierFeeModal .settings-modal-body {
    padding: 12px;
  }

  #sendLogsModal .modal-header,
  #carrierFeeModal .modal-header {
    margin: -12px -12px 10px;
    padding: 10px 12px;
  }

  #sendLogsModal .eyebrow,
  #carrierFeeModal .eyebrow {
    font-size: 11px;
  }

  #sendLogsModal .send-log-table-wrap,
  #carrierFeeModal .user-table-wrap {
    overflow: visible;
    margin-top: 8px;
  }

  #sendLogsModal .send-log-table,
  #carrierFeeModal .user-table {
    min-width: 0;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
  }

  #sendLogsModal .send-log-table thead,
  #carrierFeeModal .user-table thead {
    display: none;
  }

  #sendLogsModal .send-log-table tbody,
  #carrierFeeModal .user-table tbody {
    display: grid;
    gap: 8px;
  }

  #sendLogsModal .send-log-table tr,
  #carrierFeeModal .user-table tr {
    display: grid;
    gap: 6px;
    height: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: #fff;
  }

  #sendLogsModal .send-log-table td,
  #carrierFeeModal .user-table td {
    display: flex;
    width: 100%;
    height: auto;
    max-height: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 0;
    padding: 0;
    white-space: normal;
    word-break: break-word;
    background: transparent;
    font-size: 12px;
    text-align: right;
  }

  #sendLogsModal .send-log-table td::before,
  #carrierFeeModal .user-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-weight: 700;
    text-align: left;
  }

  #sendLogsModal .send-log-table td:first-child,
  #carrierFeeModal .user-table td:first-child {
    position: static;
    font-size: 13px;
    font-weight: 700;
    text-align: right;
  }

  #sendLogsModal .send-log-table td:last-child,
  #carrierFeeModal .user-table td:last-child {
    justify-content: flex-end;
  }

  #carrierFeeModal .settings-layout {
    gap: 10px;
    margin-top: 8px;
  }

  #carrierFeeModal .settings-section {
    gap: 8px;
    border-radius: 8px;
    padding: 10px;
  }

  #carrierFeeModal .settings-heading {
    align-items: start;
    gap: 8px;
  }

  #carrierFeeModal .settings-heading h3,
  #carrierFeeModal .user-create-form h3 {
    font-size: 14px;
  }

  #carrierFeeModal .settings-heading .hint,
  #carrierFeeModal .hint {
    font-size: 11px;
    line-height: 1.35;
  }

  #carrierFeeModal .account-action-row,
  #carrierFeeModal .backup-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  #carrierFeeModal .account-action-row .danger-text-button,
  #carrierFeeModal .backup-actions .danger-button {
    grid-column: 1 / -1;
  }

  #carrierFeeModal .user-management,
  #carrierFeeModal .settings-two-column {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 8px;
  }

  #carrierFeeModal .user-list-panel,
  #carrierFeeModal .user-create-form {
    padding: 10px;
  }

  #carrierFeeModal .user-create-form {
    grid-template-columns: 1fr;
  }

  #carrierFeeModal .carrier-fee-list {
    gap: 7px;
    margin: 8px 0;
  }

  #carrierFeeModal .carrier-fee-row {
    grid-template-columns: minmax(0, 1fr) 74px auto;
    gap: 6px;
  }

  #carrierFeeModal .carrier-fee-form,
  #carrierFeeModal .container-type-form {
    grid-template-columns: 1fr auto;
    gap: 7px;
  }

  #carrierFeeModal .container-type-list {
    gap: 6px;
  }

  #carrierFeeModal .settings-modal-body {
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    padding: 0;
  }

  #carrierFeeModal .settings-modal-body > .modal-header {
    margin: 0;
    padding: 10px 12px;
  }

  #carrierFeeModal .settings-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
  }

  #carrierFeeModal .settings-nav {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid #dce5ef;
    padding: 8px 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  #carrierFeeModal .settings-nav::-webkit-scrollbar {
    display: none;
  }

  #carrierFeeModal .settings-nav-label {
    display: none;
  }

  #carrierFeeModal .settings-nav-item {
    flex: 0 0 auto;
    width: auto;
    min-height: 38px;
    padding: 7px 12px;
    white-space: nowrap;
  }

  #carrierFeeModal .settings-nav-item span {
    display: none;
  }

  #carrierFeeModal .settings-content {
    padding: 12px;
  }

  #carrierFeeModal .settings-panel {
    gap: 10px;
  }

  #carrierFeeModal .settings-panel-header {
    min-height: 0;
    padding: 0 2px 12px;
  }

  #carrierFeeModal .settings-panel-header h3 {
    font-size: 18px;
  }

  #carrierFeeModal .settings-panel-header p:not(.settings-kicker) {
    font-size: 12px;
  }

  #carrierFeeModal .settings-status,
  #carrierFeeModal .settings-count {
    min-height: 24px;
    padding: 0 8px;
  }

  #carrierFeeModal .settings-heading h4,
  #carrierFeeModal .user-create-form h4 {
    font-size: 14px;
  }

  #carrierFeeModal .customer-create-form {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin: 16px -14px -14px;
    border-top: 1px solid var(--line);
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    background: #fff;
  }

  .modal-actions .modal-customer-field {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    margin-right: 0;
  }

  .order-modal-body .modal-actions {
    margin-top: 16px;
    padding-top: 12px;
  }

  .form-section,
  .order-modal-body .form-section,
  .paste-recognition,
  .settings-section {
    padding: 12px;
  }

  .order-modal-body .paired-section .form-grid,
  .paired-section .form-grid,
  .bill-form-grid {
    grid-template-columns: 1fr;
  }

  .order-modal-body input,
  .order-modal-body select,
  input,
  select,
  textarea {
    min-height: 34px;
    font-size: 14px;
  }

  #ordersView .controls-panel button,
  #ordersView .controls-panel input,
  #ordersView .controls-panel select,
  #billsView .controls-panel button,
  #billsView .controls-panel input,
  #billsView .controls-panel select {
    min-height: 30px;
    height: 30px;
    font-size: 11px;
  }

  .image-preview-list {
    grid-template-columns: 1fr;
  }

  .detail-field {
    min-height: auto;
  }

  .empty-row {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
  }

  .empty-row td {
    display: grid;
    justify-content: center;
    min-height: 150px;
  }

  .empty-row td::before {
    content: "";
    display: none;
  }

  .template-list {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 0 14px;
  }
}

@media (min-width: 430px) and (max-width: 760px) {
  .sidebar {
    gap: 10px;
    padding: 16px 14px 14px;
  }

  .brand strong {
    font-size: 20px;
  }

  .nav-list {
    height: 34px;
    max-height: 34px;
    gap: 8px;
  }

  .nav-list > .nav-item,
  .nav-group .nav-item {
    height: 34px;
    min-height: 34px;
    max-height: 34px;
    border-radius: 14px;
    padding: 0 12px;
    font-size: 13px;
  }

  .workspace {
    gap: 10px;
    padding: 10px;
  }

  .controls-panel {
    padding: 10px;
  }

  #ordersView .controls-panel,
  #billsView .controls-panel {
    gap: 8px;
  }

  #ordersView .controls-panel button,
  #ordersView .controls-panel input,
  #ordersView .controls-panel select,
  #billsView .controls-panel button,
  #billsView .controls-panel input,
  #billsView .controls-panel select {
    min-height: 34px;
    height: 34px;
    font-size: 12px;
  }

  #ordersView .search-field input,
  #ordersView .select-field select,
  #billsView .search-field input {
    font-size: 13px;
  }

  .bill-type-filter {
    grid-template-columns: 38px minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  .bill-type-filter > span,
  .bill-type-filter .filter-chip {
    font-size: 12px;
  }

  table {
    font-size: 12px;
  }

  th {
    font-size: 12px;
  }

  th,
  td {
    height: 38px;
    max-height: 38px;
  }

  .status-pill {
    min-height: 24px;
    font-size: 12px;
  }

  #ordersView table {
    min-width: 520px;
  }

  #ordersView th:nth-child(2),
  #ordersView td:nth-child(2) {
    width: 132px;
  }

  #ordersView th:nth-child(3),
  #ordersView td:nth-child(3) {
    width: 82px;
  }

  #ordersView th:last-child,
  #ordersView td:last-child {
    width: 196px;
  }

  #billsView table {
    min-width: 540px;
  }

  #billsView th:nth-child(2),
  #billsView td:nth-child(2) {
    width: 170px;
  }

  #billsView th:nth-child(3),
  #billsView td:nth-child(3) {
    width: 58px;
  }

  #billsView th:nth-child(4),
  #billsView td:nth-child(4) {
    width: 46px;
  }

  #billsView th:nth-child(5),
  #billsView td:nth-child(5) {
    width: 72px;
  }

  #billsView th:last-child,
  #billsView td:last-child {
    width: 170px;
  }

  .link-button {
    min-height: 28px;
    padding: 0 8px;
    font-size: 12px;
  }

  #sendLogsModal .send-log-table td,
  #carrierFeeModal .user-table td {
    font-size: 13px;
  }
}
