* { box-sizing: border-box; }
body {
  margin: 0;
  background: #f4f6f8;
  color: #1d2530;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}
body.modal-open { overflow: hidden; }
.hidden { display: none !important; }
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #14222c;
}
.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.22);
}
.login-card h1 { margin: 0; font-size: 26px; }
.login-card p { margin: 0 0 8px; color: #667085; }
.layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: 100vh;
}
aside {
  background: #13232e;
  color: #fff;
  padding: 18px 14px;
}
.brand { padding: 8px; margin-bottom: 12px; }
.brand strong { display: block; font-size: 18px; }
.brand span { display: block; margin-top: 4px; color: #b9c8d1; font-size: 12px; }
nav { display: grid; gap: 6px; }
nav button {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dce9ef;
  text-align: left;
  cursor: pointer;
}
nav button.active, nav button:hover { background: #243c4a; color: #fff; }
.nav-group {
  display: grid;
  gap: 4px;
}
.nav-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  color: #b9c8d1;
  font-size: 14px;
  font-weight: 700;
}
.nav-group-title:hover {
  background: #1d3340;
}
.nav-caret {
  color: #9fb3bf;
  font-size: 12px;
  transition: transform 0.16s ease;
}
.nav-sub {
  display: none;
  gap: 4px;
  padding: 2px 0 6px;
}
.nav-group.open .nav-sub {
  display: grid;
}
.nav-group.open .nav-caret {
  transform: rotate(180deg);
}
.nav-sub button {
  padding-left: 22px;
  font-size: 14px;
}
main { padding: 22px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { margin: 18px 0 8px; font-size: 16px; }
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-title h2 { margin: 0; }
.panel {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid #dfe5ec;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(29, 37, 48, 0.06);
}
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.order-form-errors {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #e3b7b7;
  border-radius: 8px;
  background: #fff5f5;
  color: #8f2727;
}
.order-form-errors strong {
  display: block;
  margin-bottom: 5px;
}
.order-form-errors ul {
  margin: 0;
  padding-left: 20px;
}
.order-form-layout {
  display: grid;
  grid-template-columns: minmax(640px, 1fr) minmax(300px, 350px);
  gap: 20px;
  align-items: start;
}
.order-form-main {
  display: grid;
  gap: 22px;
  min-width: 0;
}
.order-form-section {
  min-width: 0;
}
.order-form-section + .order-form-section {
  padding-top: 18px;
  border-top: 1px solid #dfe5ec;
}
.order-step-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
}
.order-step-heading h3 {
  margin: 0;
  font-size: 17px;
}
.order-step-number {
  display: grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: #176b87;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.order-items-table {
  overflow: visible;
}
.order-items-table table {
  margin-top: 0;
}
.order-item-actions {
  margin-top: 10px;
}
.order-address-editor {
  min-width: 0;
}
.order-address-group {
  display: grid;
  grid-template-columns: minmax(120px, 0.55fr) minmax(150px, 0.8fr) minmax(180px, 1fr);
  gap: 10px 12px;
  padding: 12px 0;
  border-top: 1px solid #dfe5ec;
}
.order-address-group:first-child {
  padding-top: 0;
  border-top: 0;
}
.order-address-group textarea {
  min-height: 72px;
}
.order-address-remove {
  grid-column: 1 / -1;
  justify-content: flex-end;
}
.order-address-toolbar {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  padding-top: 10px;
  border-top: 1px solid #dfe5ec;
}
.order-address-toolbar small {
  flex: 1 1 auto;
  color: #667085;
}
.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
}
.check-line input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  min-height: 18px;
  margin: 0;
}
.check-line span {
  color: #1d2530;
}
.order-settlement-column {
  min-width: 0;
}
.order-settlement-sticky {
  position: sticky;
  top: 16px;
  padding-left: 18px;
  border-left: 1px solid #dfe5ec;
}
.order-settlement-fields {
  display: grid;
  gap: 10px;
}
.order-discount-fields {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 8px;
}
.order-settlement-preview {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding: 12px 0;
  border-top: 1px solid #dfe5ec;
  border-bottom: 1px solid #dfe5ec;
}
.order-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #667085;
  font-size: 13px;
}
.order-summary-row strong {
  color: #1d2530;
}
.order-summary-total {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px dashed #d8dee8;
  font-size: 15px;
}
.order-summary-total strong {
  font-size: 19px;
}
.order-summary-balance {
  color: #7a4b08;
}
.order-summary-balance strong {
  color: #7a4b08;
}
.order-checklist {
  display: grid;
  gap: 5px;
  margin-top: 12px;
}
.order-checklist-title {
  margin-bottom: 2px;
  color: #1d2530;
  font-size: 13px;
  font-weight: 700;
}
.order-checklist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #667085;
  font-size: 12px;
}
.order-checklist-item strong {
  color: #9b2c2c;
  font-weight: 600;
}
.order-checklist-item.is-complete strong {
  color: #276738;
}
.order-submit-button {
  width: 100%;
  min-height: 42px;
  margin-top: 14px;
}
.order-field-error input,
.order-field-error select,
.order-field-error textarea {
  border-color: #c84b4b;
  background: #fffafa;
}
.order-field-error td {
  background: #fffafa;
}
.order-field-error span:first-child {
  color: #9b2c2c;
}
.compact-filter {
  margin: 8px 0 12px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.card {
  padding: 14px;
  border: 1px solid #dfe5ec;
  border-radius: 8px;
  background: #fafbfd;
}
.card span { display: block; color: #667085; font-size: 12px; }
.card strong { display: block; margin-top: 6px; font-size: 22px; }
.admin-dashboard {
  display: grid;
  gap: 16px;
}
.dashboard-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 4px 2px 2px;
}
.dashboard-heading h2,
.dashboard-panel-heading h3 {
  margin: 0;
  letter-spacing: 0;
}
.dashboard-heading h2 {
  font-size: 24px;
}
.dashboard-heading p:not(.dashboard-eyebrow) {
  margin: 7px 0 0;
  color: #667085;
  font-size: 13px;
}
.dashboard-eyebrow {
  margin: 0 0 5px;
  color: #667085;
  font-size: 12px;
  font-weight: 700;
}
.dashboard-period {
  min-width: 68px;
  padding: 8px 12px;
  border: 1px solid #dfe5ec;
  border-radius: 8px;
  background: #fff;
  color: #40505e;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}
.dashboard-filter-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  border: 1px solid #dfe5ec;
  border-radius: 8px;
  background: #fff;
}
.dashboard-filter-title {
  display: grid;
  gap: 3px;
  min-width: 170px;
}
.dashboard-filter-title span {
  color: #667085;
  font-size: 12px;
}
.dashboard-filter-title strong {
  color: #25313b;
  font-size: 14px;
}
.dashboard-filter-controls {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 14px;
  min-width: 0;
}
.dashboard-range-presets button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #52616e;
  cursor: pointer;
}
.dashboard-range-presets button:hover {
  background: #edf3f6;
  color: #176b87;
}
.dashboard-range-presets button.active {
  background: #176b87;
  color: #fff;
}
.dashboard-custom-range {
  display: grid;
  grid-template-columns: minmax(135px, 160px) auto minmax(135px, 160px) auto;
  gap: 8px;
  align-items: end;
}
.dashboard-custom-range label {
  gap: 4px;
  font-size: 11px;
}
.dashboard-custom-range input {
  min-height: 36px;
}
.dashboard-custom-range .primary {
  min-height: 36px;
  white-space: nowrap;
}
.dashboard-range-separator {
  padding-bottom: 9px;
  color: #8a95a2;
  font-size: 12px;
}
.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.dashboard-metric {
  --metric-color: #2d7fa3;
  min-width: 0;
  min-height: 132px;
  padding: 16px 16px 14px;
  border: 1px solid #dfe5ec;
  border-top: 4px solid var(--metric-color);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 5px 14px rgba(29, 37, 48, 0.05);
}
.dashboard-metric.blue { --metric-color: #2d7fa3; }
.dashboard-metric.teal { --metric-color: #16827f; }
.dashboard-metric.green { --metric-color: #3f8c67; }
.dashboard-metric.coral { --metric-color: #d86f5c; }
.dashboard-metric.gold { --metric-color: #d59a29; }
.dashboard-metric span,
.dashboard-metric small {
  display: block;
}
.dashboard-metric span {
  color: #667085;
  font-size: 13px;
}
.dashboard-metric strong {
  display: block;
  margin: 10px 0 8px;
  color: #17232d;
  font-size: 25px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.dashboard-metric small {
  color: #8a95a2;
  font-size: 11px;
}
.dashboard-grid {
  display: grid;
  gap: 16px;
}
.dashboard-grid-primary {
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr);
}
.dashboard-grid-secondary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.dashboard-panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid #dfe5ec;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 6px 16px rgba(29, 37, 48, 0.05);
}
.dashboard-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.dashboard-panel-heading h3 {
  font-size: 17px;
}
.dashboard-link-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #fff;
  color: #40505e;
  cursor: pointer;
  white-space: nowrap;
}
.dashboard-link-button:hover {
  border-color: #2d7fa3;
  color: #176b87;
}
.dashboard-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #667085;
  font-size: 12px;
}
.dashboard-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.legend-dot.sales { background: #16827f; }
.legend-dot.receipts { background: #d59a29; }
.dashboard-trend-chart {
  width: 100%;
  overflow-x: auto;
}
.dashboard-trend-chart svg {
  display: block;
  width: 100%;
  min-width: 620px;
  height: auto;
}
.trend-grid-line {
  stroke: #e7ebef;
  stroke-width: 1;
}
.trend-axis-label,
.trend-date-label,
.trend-order-label {
  fill: #7b8794;
  font-size: 11px;
}
.trend-order-label {
  fill: #a0a8b1;
  font-size: 9px;
}
.trend-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}
.trend-line.sales { stroke: #16827f; }
.trend-line.receipts { stroke: #d59a29; }
.trend-point {
  stroke: #fff;
  stroke-width: 2;
}
.trend-point.sales { fill: #16827f; }
.trend-point.receipts { fill: #d59a29; }
.dashboard-status-layout {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(150px, 1fr);
  gap: 22px;
  align-items: center;
  min-height: 250px;
}
.dashboard-donut {
  display: grid;
  width: 176px;
  height: 176px;
  place-items: center;
  margin: 0 auto;
  border-radius: 50%;
}
.dashboard-donut > div {
  display: grid;
  width: 110px;
  height: 110px;
  place-items: center;
  align-content: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px #edf0f3;
}
.dashboard-donut strong,
.dashboard-donut span {
  display: block;
  text-align: center;
}
.dashboard-donut strong {
  font-size: 30px;
  line-height: 1;
}
.dashboard-donut span {
  margin-top: 6px;
  color: #667085;
  font-size: 11px;
}
.dashboard-status-legend {
  display: grid;
  gap: 9px;
}
.dashboard-status-legend > div {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: #52616e;
  font-size: 13px;
}
.dashboard-status-legend i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
}
.dashboard-status-legend strong {
  color: #1d2530;
}
.dashboard-payment-list {
  display: grid;
  gap: 15px;
}
.dashboard-payment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 12px;
  align-items: start;
}
.dashboard-payment-row > div:first-child {
  min-width: 0;
}
.dashboard-payment-row strong,
.dashboard-payment-row span {
  display: block;
}
.dashboard-payment-row strong {
  color: #25313b;
  font-size: 14px;
}
.dashboard-payment-row span {
  margin-top: 3px;
  color: #7b8794;
  font-size: 11px;
  overflow-wrap: anywhere;
}
.dashboard-payment-row > b {
  color: #176b87;
  font-size: 14px;
}
.dashboard-payment-track {
  grid-column: 1 / -1;
  height: 7px;
  overflow: hidden;
  border-radius: 4px;
  background: #edf1f4;
}
.dashboard-payment-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #2d7fa3;
}
.dashboard-task-list {
  display: grid;
}
.dashboard-task-row {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) auto 14px;
  gap: 11px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 9px 4px;
  border: 0;
  border-bottom: 1px solid #edf0f3;
  border-radius: 0;
  background: transparent;
  color: #1d2530;
  text-align: left;
  cursor: pointer;
}
.dashboard-task-row:last-child {
  border-bottom: 0;
}
.dashboard-task-row:hover {
  background: #f8fafb;
}
.task-accent {
  width: 4px;
  height: 30px;
  border-radius: 2px;
  background: #2d7fa3;
}
.task-accent.blue { background: #2d7fa3; }
.task-accent.gold { background: #d59a29; }
.task-accent.coral { background: #d86f5c; }
.task-accent.green { background: #3f8c67; }
.dashboard-task-row strong,
.dashboard-task-row small {
  display: block;
}
.dashboard-task-row strong {
  font-size: 13px;
}
.dashboard-task-row small {
  margin-top: 3px;
  color: #7b8794;
  font-size: 11px;
}
.dashboard-task-row b {
  min-width: 28px;
  color: #1d2530;
  font-size: 18px;
  text-align: right;
}
.task-arrow {
  color: #9aa4ae;
  font-size: 22px;
  line-height: 1;
}
.dashboard-empty {
  margin: 0;
  padding: 36px 12px;
  color: #8a95a2;
  text-align: center;
}
.segment-control {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid #dfe5ec;
  border-radius: 8px;
  background: #fafbfd;
}
.segment-control button {
  min-width: 64px;
  min-height: 34px;
}
.sales-chart-scroll {
  max-width: 100%;
  padding: 12px 4px 4px;
  overflow-x: auto;
}
.sales-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-width: max-content;
  min-height: 260px;
  padding: 18px 8px 0;
  border-bottom: 1px solid #d8dee8;
}
.sales-chart-column {
  display: grid;
  grid-template-rows: 24px 184px auto;
  align-items: end;
  justify-items: center;
  width: 58px;
  min-width: 58px;
  color: #667085;
  font-size: 11px;
  text-align: center;
}
.sales-chart-column strong {
  align-self: start;
  color: #1d2530;
  font-size: 12px;
}
.sales-chart-bar-track {
  display: flex;
  align-items: flex-end;
  width: 28px;
  height: 184px;
}
.sales-chart-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  background: #176b87;
}
.sales-chart-column span {
  min-height: 32px;
  padding-top: 7px;
  line-height: 1.25;
}
label { display: grid; gap: 6px; color: #667085; font-size: 13px; }
.contact-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #fff;
  color: #1d2530;
}
textarea {
  min-height: 84px;
  padding-top: 10px;
  resize: vertical;
}
.wide { grid-column: 1 / -1; }
.order-search-box { display: grid; gap: 8px; }
.search-results {
  display: grid;
  gap: 6px;
  max-height: 230px;
  overflow: auto;
}
.result-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #dfe5ec;
  border-radius: 8px;
  background: #fff;
  color: #1d2530;
  text-align: left;
  cursor: pointer;
}
.result-item:hover {
  border-color: #176b87;
  background: #f5fbfd;
}
.product-picker {
  position: relative;
  display: grid;
  gap: 6px;
}
.inbound-batch-head {
  display: grid;
  grid-template-columns: minmax(220px, 320px);
  margin: 14px 0 8px;
}
.inbound-entry-table {
  min-width: 920px;
  table-layout: fixed;
}
.inbound-entry-table .inbound-code-col { width: 24%; }
.inbound-entry-table .inbound-name-col { width: 25%; }
.inbound-entry-table .inbound-appearance-col { width: 29%; }
.inbound-entry-table .inbound-qty-col { width: 14%; }
.inbound-entry-table .inbound-action-col { width: 8%; }
.inbound-entry-table td {
  position: relative;
  vertical-align: top;
}
.inbound-entry-table .inbound-product-results {
  position: absolute;
  top: calc(100% + 2px);
  right: 0;
  left: 0;
  z-index: 8;
  padding: 6px;
  border: 1px solid #dfe5ec;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(29, 37, 48, 0.14);
}
.inbound-remove-row {
  width: 100%;
  min-height: 38px;
  padding: 0 8px;
}
.inbound-batch-actions {
  margin-top: 14px;
}
.compact-result {
  padding: 8px 10px;
}
.result-item span,
.muted {
  color: #667085;
  font-size: 12px;
}
.selected-record {
  padding: 10px 12px;
  border: 1px solid #b6dfc2;
  border-radius: 8px;
  background: #f2fbf4;
  color: #276738;
  font-size: 13px;
}
.muted { padding: 10px; }
.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
.primary, .ghost {
  min-height: 36px;
  padding: 0 13px;
  border-radius: 8px;
  cursor: pointer;
}
.primary {
  border: 1px solid #176b87;
  background: #176b87;
  color: #fff;
}
.primary:disabled,
.ghost:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.ghost {
  border: 1px solid #d8dee8;
  background: #fff;
  color: #1d2530;
}
.ghost.danger {
  border-color: #e3b7b7;
  color: #9b2c2c;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 29, 38, 0.58);
}
.modal-window {
  display: flex;
  flex-direction: column;
  width: min(960px, 100%);
  max-height: calc(100vh - 48px);
  overflow: hidden;
  border: 1px solid #dfe5ec;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 64px rgba(16, 29, 38, 0.26);
}
.modal-medium {
  width: min(680px, 100%);
}
.modal-wide {
  width: min(1280px, 100%);
}
.modal-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  padding: 12px 18px;
  border-bottom: 1px solid #dfe5ec;
  background: #fff;
}
.modal-header h2 {
  margin: 0;
  font-size: 20px;
}
.modal-close {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #fff;
  color: #667085;
  cursor: pointer;
  font-size: 18px;
}
.modal-close:hover {
  border-color: #176b87;
  color: #176b87;
}
.modal-body {
  min-height: 0;
  padding: 18px;
  overflow: auto;
}
.modal-form .notice {
  margin: 0;
}
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  background: #fff;
}
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}
th, td {
  padding: 8px;
  border: 1px solid #dfe5ec;
  text-align: left;
  vertical-align: top;
}
th {
  background: #fafbfd;
  color: #667085;
  font-size: 13px;
}
.notice {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #f1d7a7;
  border-radius: 8px;
  background: #fff8eb;
  color: #7a4b08;
}
.focus-panel {
  outline: 2px solid #176b87;
  outline-offset: 3px;
}
.hint { color: #667085; font-size: 12px; line-height: 1.6; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.detail-tabs {
  position: sticky;
  top: -18px;
  z-index: 2;
  display: flex;
  gap: 4px;
  margin: -18px -18px 18px;
  padding: 12px 18px 0;
  overflow-x: auto;
  border-bottom: 1px solid #dfe5ec;
  background: #fff;
}
.detail-tab-button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #667085;
  cursor: pointer;
  font-weight: 600;
}
.detail-tab-button:hover {
  color: #176b87;
}
.detail-tab-button.active {
  border-bottom-color: #176b87;
  color: #176b87;
}
.detail-tab-panel {
  display: none;
}
.detail-tab-panel.active {
  display: block;
}
.detail-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}
.detail-summary > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid #dfe5ec;
  border-radius: 6px;
  background: #fafbfd;
}
.detail-summary dt {
  margin-bottom: 6px;
  color: #667085;
  font-size: 12px;
}
.detail-summary dd {
  margin: 0;
  color: #1d2530;
  font-size: 17px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.detail-block {
  margin-top: 18px;
}
.detail-block h3 {
  margin: 0 0 8px;
}
.detail-action-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.compact-cell {
  display: grid;
  gap: 3px;
  min-width: 120px;
}
.compact-cell strong {
  color: #1d2530;
  font-weight: 650;
}
.compact-cell span {
  color: #667085;
  font-size: 12px;
  line-height: 1.45;
}
.compact-lines {
  display: grid;
  gap: 8px;
}
.line-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(90px, 0.5fr) minmax(150px, 1fr) minmax(150px, 1fr) auto;
  gap: 8px;
  align-items: end;
}
.after-sale-resend-line {
  grid-template-columns: minmax(260px, 1.6fr) minmax(120px, 0.55fr) auto;
}
.after-sale-resend-line > button {
  width: auto;
}
@media (max-width: 1380px) {
  .order-form-layout {
    grid-template-columns: 1fr;
  }
  .order-settlement-sticky {
    position: static;
    padding: 18px 0 0;
    border-top: 1px solid #dfe5ec;
    border-left: 0;
  }
  .order-settlement-fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .order-discount-fields {
    display: contents;
  }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  aside { position: static; }
  nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid, .cards { grid-template-columns: 1fr; }
  .dashboard-filter-panel {
    align-items: stretch;
    flex-direction: column;
  }
  .dashboard-filter-controls {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .dashboard-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dashboard-grid-primary,
  .dashboard-grid-secondary {
    grid-template-columns: minmax(0, 1fr);
  }
  .order-form-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .order-settlement-fields {
    grid-template-columns: 1fr;
  }
  .order-discount-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .order-address-group {
    grid-template-columns: 1fr 1fr;
  }
  .order-address-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .order-address-toolbar button {
    align-self: flex-start;
  }
  .line-row { grid-template-columns: 1fr; }
  .detail-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  main { padding: 14px; }
}

@media (max-width: 640px) {
  body {
    background: #f6f8fb;
    -webkit-text-size-adjust: 100%;
  }
  .login-screen {
    padding: 14px;
    align-items: start;
  }
  .login-card {
    margin-top: 8vh;
    padding: 20px;
  }
  .login-card h1 {
    font-size: 22px;
  }
  .layout {
    display: block;
  }
  .dashboard-heading {
    align-items: flex-start;
  }
  .dashboard-filter-controls {
    display: grid;
  }
  .dashboard-range-presets {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .dashboard-range-presets button {
    min-width: 0;
  }
  .dashboard-custom-range {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dashboard-range-separator {
    display: none;
  }
  .dashboard-custom-range .primary {
    grid-column: 1 / -1;
  }
  .dashboard-panel {
    padding: 14px;
  }
  .dashboard-panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .dashboard-panel-heading .dashboard-legend {
    align-self: flex-start;
  }
  .dashboard-status-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .dashboard-status-legend {
    width: min(320px, 100%);
    margin: 0 auto;
  }
  aside {
    position: sticky;
    top: 0;
    z-index: 20;
    max-height: 46vh;
    overflow: auto;
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }
  .brand {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    padding: 4px 6px;
  }
  .brand strong {
    font-size: 16px;
    white-space: nowrap;
  }
  .brand span {
    margin-top: 0;
    text-align: right;
  }
  nav {
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
  }
  .nav-group {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    overflow: hidden;
  }
  .nav-group-title,
  nav button {
    min-height: 44px;
    border-radius: 0;
    font-size: 15px;
  }
  .nav-sub {
    grid-template-columns: 1fr 1fr;
    gap: 0;
    padding: 0;
  }
  .nav-sub button {
    min-height: 42px;
    padding-left: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 14px;
  }
  main {
    padding: 12px;
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    align-items: center;
    margin: -12px -12px 12px;
    padding: 10px 12px;
    border-bottom: 1px solid #dfe5ec;
    background: rgba(246, 248, 251, 0.96);
    backdrop-filter: blur(8px);
  }
  h1 {
    max-width: calc(100vw - 110px);
    margin: 0;
    font-size: 22px;
    line-height: 1.25;
    word-break: break-word;
  }
  h2 {
    font-size: 18px;
  }
  h3 {
    font-size: 15px;
  }
  .panel {
    margin-bottom: 12px;
    padding: 12px;
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(29, 37, 48, 0.05);
  }
  .order-form-layout,
  .order-form-main,
  .order-form-section,
  .order-settlement-column {
    min-width: 0;
  }
  .order-items-table {
    max-width: 100%;
    overflow-x: auto;
  }
  .order-settlement-sticky {
    padding-top: 14px;
  }
  .order-discount-fields {
    grid-template-columns: 1fr;
  }
  .order-address-group {
    grid-template-columns: 1fr;
  }
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }
  .segment-control {
    align-self: flex-start;
  }
  .cards {
    gap: 8px;
  }
  .card {
    padding: 10px 12px;
  }
  .card strong {
    font-size: 19px;
  }
  .grid {
    gap: 10px;
  }
  .contact-pair {
    grid-template-columns: 1fr;
  }
  .inbound-batch-head {
    grid-template-columns: minmax(0, 1fr);
  }
  label {
    font-size: 13px;
  }
  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }
  textarea {
    min-height: 96px;
  }
  .actions,
  .row-actions {
    justify-content: stretch;
    gap: 8px;
  }
  .actions > button,
  .row-actions > button,
  .row-actions > select {
    flex: 1 1 auto;
  }
  .primary,
  .ghost {
    min-height: 44px;
    padding: 0 12px;
  }
  table {
    min-width: 720px;
    font-size: 14px;
  }
  th,
  td {
    padding: 8px 10px;
  }
  .search-results {
    max-height: 280px;
  }
  .result-item {
    min-height: 48px;
  }
  .notice {
    padding: 9px 10px;
    font-size: 14px;
    line-height: 1.55;
  }
  .compact-filter {
    margin-top: 6px;
  }
  .line-row {
    gap: 10px;
  }
  .modal-backdrop {
    place-items: end center;
    padding: 0;
  }
  .modal-window {
    width: 100%;
    max-height: 94vh;
    border-width: 1px 0 0;
    border-radius: 8px 8px 0 0;
  }
  .modal-header {
    min-height: 58px;
    padding: 9px 12px;
  }
  .modal-header h2 {
    font-size: 18px;
  }
  .modal-body {
    padding: 12px;
  }
  .detail-tabs {
    top: -12px;
    margin: -12px -12px 14px;
    padding: 8px 12px 0;
  }
  .detail-summary {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .detail-action-bar {
    justify-content: stretch;
  }
  .detail-action-bar > button {
    flex: 1 1 auto;
  }
}

@media (max-width: 420px) {
  .dashboard-range-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dashboard-custom-range {
    grid-template-columns: 1fr;
  }
  .dashboard-kpis {
    grid-template-columns: 1fr;
  }
  .dashboard-heading {
    flex-direction: column;
  }
  .dashboard-period {
    align-self: flex-start;
  }
  .dashboard-metric {
    min-height: 116px;
  }
  .dashboard-payment-row {
    grid-template-columns: 1fr;
  }
  .dashboard-payment-row > b {
    justify-self: start;
  }
  .dashboard-payment-track {
    grid-column: 1;
  }
  .nav-sub {
    grid-template-columns: 1fr;
  }
  .brand {
    align-items: start;
    flex-direction: column;
  }
  .brand span {
    text-align: left;
  }
  .detail-summary {
    grid-template-columns: 1fr;
  }
  table {
    min-width: 660px;
  }
}
