:root {
  --bg-main: linear-gradient(135deg, #e7fbff 0%, #f2f9ff 56%, #e8f4ff 100%);
  --panel-bg: #ffffff;
  --text-main: #0b2337;
  --text-sub: #547086;
  --brand: #0284c7;
  --brand-2: #06b6d4;
  --danger: #dc2626;
  --success: #16a34a;
  --border: #cfe5f1;
  --shadow: 0 12px 32px rgba(3, 35, 65, 0.08);
  --radius-xl: 18px;
  --radius-lg: 12px;
  --radius-md: 10px;
  --ease-smooth: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text-main); }
body { background: #edf6fb; }

.login-page {
  min-height: 100vh;
  background: var(--bg-main);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.bg-bubble {
  position: absolute;
  width: 360px;
  height: 360px;
  border-radius: 999px;
  filter: blur(70px);
  opacity: 0.25;
}

.bubble-a { right: -120px; top: -120px; background: #60a5fa; }
.bubble-b { left: -120px; bottom: -120px; background: #818cf8; }

.login-layout {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: center;
  position: relative;
  z-index: 2;
}

.login-layout-single {
  max-width: 560px;
  grid-template-columns: 1fr;
}

.login-card,
.wechat-card,
.panel,
.modal-dialog {
  background: var(--panel-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  transition: transform .22s var(--ease-smooth), box-shadow .22s var(--ease-smooth);
}

.login-card {
  padding: 42px;
}

.login-header h1 {
  margin: 0;
  font-size: 36px;
  line-height: 1.2;
  font-weight: 700;
}

.login-header h1 span {
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-header p {
  margin: 12px 0 24px;
  color: var(--text-sub);
}

.form-stack { display: grid; gap: 12px; }
.field-label { font-size: 14px; color: #374151; }
.input-wrap { position: relative; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  min-height: 42px;
  outline: none;
  font-size: 14px;
  background: #fff;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #67d6ff;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, .18);
}

.btn {
  border: 1px solid #cfd8e6;
  border-radius: var(--radius-md);
  min-height: 42px;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: #f2fbff;
  color: #0f3651;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform .16s var(--ease-smooth), box-shadow .16s var(--ease-smooth), filter .16s var(--ease-smooth), background-color .2s;
  will-change: transform;
}

.btn:hover {
  filter: none;
  background: #e6f6ff;
  border-color: #9bd3e8;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0) scale(0.99);
}

.btn:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}

.btn.loading {
  pointer-events: none;
  opacity: .8;
}

.btn.loading::after {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin .75s linear infinite;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-color: transparent;
  box-shadow: 0 10px 20px rgba(37, 99, 235, .25);
}

.btn-primary:hover {
  background: linear-gradient(90deg, #0369a1, #0891b2);
}

.btn-secondary {
  background: #dff6ff;
  color: #0369a1;
  border-color: #bae6fd;
}

.btn-secondary:hover {
  background: #cff0ff;
  border-color: #7dd3fc;
}

.btn-danger {
  background: #ffe4e6;
  color: #be123c;
  border-color: #fecdd3;
}

.btn-danger:hover {
  background: #fecdd3;
  border-color: #fda4af;
}

.btn-block { width: 100%; }

.form-msg {
  min-height: 20px;
  margin: 0;
  font-size: 13px;
  color: var(--text-sub);
}

.form-msg.error { color: #dc2626; }
.form-msg.success { color: #16a34a; }
.form-msg.info { color: #2563eb; }

.copyright { margin-top: 20px; font-size: 13px; color: #9ca3af; text-align: center; }

.wechat-card {
  padding: 26px;
  text-align: center;
}

.wechat-card h3 { margin: 0 0 8px; }
.wechat-card p { margin: 0 0 12px; color: var(--text-sub); }

.qrcode-wrap {
  margin: 0 auto 12px;
  width: 180px;
  height: 180px;
  border-radius: 16px;
  background: #f8fafc;
  display: grid;
  place-items: center;
  border: 1px solid #e2e8f0;
}

.qrcode-wrap img { width: 150px; height: 150px; object-fit: contain; }
.wechat-tip { font-size: 13px; color: #4b5563; }

.app-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 0%, rgba(103, 214, 255, 0.24), transparent 34%),
    radial-gradient(circle at 92% 8%, rgba(125, 211, 252, 0.24), transparent 30%),
    linear-gradient(145deg, #eff8fc 0%, #e8f2f9 100%);
  padding: 20px;
}

.app-header {
  max-width: 1280px;
  margin: 0 auto 16px;
  padding: 20px;
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, #ffffff 0%, #f2fbff 100%);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  box-shadow: var(--shadow);
  border: 1px solid #cde5f3;
}

.app-header h1 {
  margin: 0;
  font-size: 26px;
  color: #0b3a57;
  letter-spacing: 0.2px;
}

.app-header p { margin: 8px 0 0; color: var(--text-sub); font-size: 14px; }

.header-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.grid-two {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}

.panel {
  padding: 22px;
  border: 1px solid #d2e7f3;
}

.config-main {
  max-width: 1280px;
  margin: 0 auto;
}

.config-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.config-sidebar {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 20px;
}

.config-workbench {
  display: grid;
  gap: 14px;
}

.config-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid #d8e7ef;
  background:
    linear-gradient(180deg, #ffffff 0%, #f9fcff 100%);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.05);
}

.config-card-head {
  display: grid;
  gap: 8px;
}

.config-card-kicker {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #0c4a6e;
  background: #edf7ff;
  border: 1px solid #d4e8f7;
  text-transform: uppercase;
}

.config-card-head h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: #0f2d3c;
}

.config-card-head p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: #587284;
}

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

.config-card-grid label {
  display: grid;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  color: #4e6a7d;
}

.config-status-card {
  background:
    radial-gradient(circle at top right, rgba(245, 158, 11, 0.10), transparent 24%),
    linear-gradient(180deg, #fffdfa 0%, #ffffff 100%);
}

.config-change-summary {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 10px 14px;
  border-radius: 16px;
  background: linear-gradient(90deg, #fff7ed, #fffdf7);
  border: 1px solid #f5d8b1;
  color: #8a4b14;
  font-size: 13px;
  font-weight: 700;
}

.config-actions {
  position: sticky;
  bottom: 0;
  padding: 14px;
  border-radius: 22px;
  background: rgba(255,255,255,0.92);
  border: 1px solid #d8e7ef;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(10px);
}

.panel h2 {
  margin: 0 0 18px;
  font-size: 20px;
}

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

.form-grid label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: #374151;
}

.full-row { grid-column: 1 / -1; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.field-note {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.5;
  color: #5d7789;
}

.field-label-title {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #3f5d71;
  margin-bottom: 8px;
}

.pricing-mode-switch {
  display: grid;
  gap: 8px;
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 18px;
  background: linear-gradient(180deg, #f4f9fd 0%, #eef6fb 100%);
  border: 1px solid #d7e7f0;
  width: fit-content;
}

.segmented-option {
  position: relative;
  margin: 0;
}

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

.segmented-option span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  color: #49667a;
  cursor: pointer;
  transition: background-color .18s, color .18s, box-shadow .18s, transform .18s;
}

.segmented-option input:checked + span {
  color: #0b3a57;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.07);
}

.input-auto {
  background: linear-gradient(180deg, #f6fbff 0%, #f1f8fc 100%) !important;
  color: #537083;
}

input[readonly] {
  cursor: default;
}

.live-pricing-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: -2px;
}

.live-pricing-card {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid #d7e7f0;
  background: linear-gradient(180deg, #ffffff 0%, #f8fcff 100%);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.live-pricing-card span {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #5b7486;
}

.live-pricing-card strong {
  font-size: 24px;
  line-height: 1;
  color: #103249;
}

.live-pricing-status {
  background:
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.10), transparent 26%),
    linear-gradient(180deg, #f5fbff 0%, #ffffff 100%);
}

.live-formula-note {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid #d9e8f0;
  background: linear-gradient(180deg, #f8fcff 0%, #f3f9fd 100%);
  color: #4d6c7f;
  font-size: 13px;
  line-height: 1.6;
}

.cost-composer {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid #d7e7f0;
  background:
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.08), transparent 24%),
    linear-gradient(180deg, #ffffff 0%, #f9fcff 100%);
}

.cost-composer-head {
  display: grid;
  gap: 8px;
}

.cost-composer-kicker {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #0c4a6e;
  background: #edf7ff;
  border: 1px solid #d3e8f7;
}

.cost-composer-head h3 {
  margin: 0;
  font-size: 20px;
  color: #0f2d3c;
}

.cost-composer-head p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: #5b7486;
}

.cost-composer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.cost-card {
  display: grid !important;
  gap: 8px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid #d8e7ef;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.cost-card span {
  font-size: 12px;
  font-weight: 700;
  color: #587284;
}

.cost-card-primary {
  border-color: #bfe0ef;
  box-shadow: 0 10px 24px rgba(14, 165, 233, 0.08);
}

.target-helper-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid #d9e8ef;
  background:
    radial-gradient(circle at top right, rgba(245, 158, 11, 0.10), transparent 22%),
    linear-gradient(180deg, #fffdf9 0%, #ffffff 100%);
}

.target-helper-head {
  display: grid;
  gap: 8px;
}

.target-helper-kicker {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #92400e;
  background: #fff7ed;
  border: 1px solid #f3d2ae;
}

.target-helper-head h3 {
  margin: 0;
  font-size: 20px;
  color: #0f2d3c;
}

.target-helper-head p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: #5b7486;
}

.target-helper-body {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.target-helper-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.target-helper-result {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid #e7e1d2;
  background: linear-gradient(180deg, #fffefb 0%, #fffaf2 100%);
}

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

.multi-candidate-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.target-suggestion-item {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid #ede2ca;
  background: #ffffff;
}

.target-suggestion-item span {
  font-size: 12px;
  font-weight: 700;
  color: #6b7280;
}

.target-suggestion-item strong {
  font-size: 22px;
  color: #8a4b14;
}

.target-candidate-card {
  align-content: start;
}

.target-candidate-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.target-candidate-rank {
  font-size: 12px;
  font-weight: 800;
  color: #92400e;
}

.target-candidate-tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #7c5b19;
  background: #fff6df;
  border: 1px solid #f4ddb0;
}

.target-candidate-metrics {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: #6b7280;
}

.target-candidate-details {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fffaf2;
  border: 1px solid #efe0c2;
  font-size: 12px;
  color: #7c6643;
}

.target-suggestion-note {
  margin: 0;
  font-size: 13px;
  color: #6c5c3d;
}

.result-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.result-headline h2 {
  margin: 0;
}

.sku-output-card {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
  border-radius: 20px;
  border: 1px solid #d8e7ef;
  background:
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.08), transparent 24%),
    linear-gradient(180deg, #ffffff 0%, #f9fcff 100%);
}

.sku-output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sku-output-head span {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #537083;
}

.sku-output-card strong {
  font-size: 18px;
  line-height: 1.4;
  color: #103249;
  word-break: break-all;
}

.mode-card {
  padding: 12px;
  border: 1px solid #d2e7f3;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f3fbff 100%);
}

.mode-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
}

.config-section-title {
  margin-top: 6px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #e8f7ff;
  border: 1px solid #c6e7f5;
  color: #0b3a57;
  font-size: 14px;
  font-weight: 700;
}

.config-formula-item {
  display: none !important;
}

.freight-config-card {
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid rgba(185, 208, 221, 0.95);
  border-radius: 28px;
  background:
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.12), transparent 24%),
    radial-gradient(circle at 0% 100%, rgba(251, 191, 36, 0.10), transparent 30%),
    linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  box-shadow: 0 26px 60px rgba(15, 23, 42, 0.08);
}

.freight-config-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding-bottom: 4px;
}

.freight-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: #0f766e;
  background: linear-gradient(90deg, rgba(20, 184, 166, 0.14), rgba(14, 165, 233, 0.10));
  border: 1px solid rgba(94, 234, 212, 0.4);
}

.freight-config-head h3 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: #0f2d3c;
}

.freight-config-head p {
  margin: 0;
  color: #557082;
  font-size: 14px;
  max-width: 620px;
}

.freight-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  min-width: min(520px, 100%);
  justify-content: flex-end;
  padding: 12px;
  border-radius: 22px;
  background: rgba(241, 248, 253, 0.96);
  border: 1px solid #dceaf2;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9);
}

.freight-tools select,
.freight-tools input[type="search"] {
  min-width: 200px;
  background: rgba(255,255,255,0.96);
  border-color: #cfe0ea;
}

.freight-tools select {
  min-width: 140px;
}

.freight-summary {
  font-size: 13px;
  font-weight: 600;
  color: #24475c;
  padding: 10px 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, #eef8ff, #f8fbff);
  border: 1px solid #d5e8f5;
  width: fit-content;
}

.freight-dirty-summary {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 10px 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, #fff7ed, #fffdf8);
  border: 1px solid #f5d6b2;
  color: #8a4b14;
  font-size: 13px;
  font-weight: 700;
  width: fit-content;
}

.freight-table-wrap {
  max-height: 72vh;
  overflow: auto;
  padding-right: 6px;
  scrollbar-width: thin;
}

.freight-rule-list {
  display: grid;
  gap: 16px;
}

.freight-group-list {
  display: grid;
  gap: 16px;
}

.freight-mode-group {
  display: grid;
  gap: 12px;
  padding: 12px;
  border-radius: 24px;
  border: 1px solid #d9e8ef;
  background: linear-gradient(180deg, rgba(255,255,255,0.95) 0%, rgba(246,250,253,0.95) 100%);
}

.freight-mode-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(90deg, #edf8ff, #f9fcff);
  color: #163d52;
  cursor: pointer;
  text-align: left;
}

.freight-mode-head strong {
  display: block;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.freight-mode-head span {
  font-size: 12px;
  color: #597587;
}

.freight-mode-arrow {
  font-size: 18px;
  color: #0c4a6e;
  transition: transform .18s var(--ease-smooth);
}

.freight-mode-body {
  display: grid;
  gap: 14px;
}

.freight-mode-group[data-collapsed="1"] .freight-mode-body {
  display: none;
}

.freight-mode-group[data-collapsed="1"] .freight-mode-arrow {
  transform: rotate(-90deg);
}

.freight-rule-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  border-radius: 26px;
  border: 1px solid #d8e7ef;
  background:
    radial-gradient(circle at top right, rgba(255,255,255,0.9), transparent 24%),
    linear-gradient(180deg, #ffffff 0%, #fafdff 100%);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.05);
  transition: transform .18s var(--ease-smooth), box-shadow .18s var(--ease-smooth), border-color .18s;
  position: relative;
  overflow: hidden;
}

.freight-rule-card:hover {
  transform: translateY(-2px);
  border-color: #aed5e8;
  box-shadow: 0 18px 40px rgba(14, 165, 233, 0.09);
}

.freight-rule-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, #0ea5e9, #14b8a6);
  opacity: 0.92;
}

.freight-rule-card[data-enabled="0"] {
  opacity: 0.72;
  background: linear-gradient(180deg, #fcfdfe 0%, #f5f8fa 100%);
}

.freight-rule-card[data-enabled="0"]::before {
  background: linear-gradient(180deg, #94a3b8, #cbd5e1);
}

.freight-rule-card[data-enabled="0"] .freight-badge,
.freight-rule-card[data-enabled="0"] .freight-rule-overview,
.freight-rule-card[data-enabled="0"] .btn-danger {
  filter: saturate(0.78);
}

.freight-rule-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.freight-rule-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.freight-switch {
  display: inline-flex !important;
  align-items: center;
  gap: 10px;
  font-size: 13px !important;
  font-weight: 700;
  color: #1f4257 !important;
}

.freight-rule-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}

.freight-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.65);
}

.freight-badge-mode {
  color: #0f766e;
  background: linear-gradient(180deg, #f0fdfa 0%, #dffaf5 100%);
  border-color: #baf0e6;
}

.freight-badge-channel {
  color: #075985;
  background: linear-gradient(180deg, #f5f9ff 0%, #e3f0ff 100%);
  border-color: #c8ddff;
}

.freight-badge-source {
  color: #7c5b19;
  background: linear-gradient(180deg, #fffaf0 0%, #fff0c9 100%);
  border-color: #f3de9f;
}

.freight-badge-dirty {
  color: #92400e;
  background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
  border-color: #fdba74;
}

.freight-badge-created {
  color: #166534;
  background: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%);
  border-color: #86efac;
}

.freight-badge-updated {
  color: #9a3412;
  background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
  border-color: #fdba74;
}

.freight-rule-overview {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #f7fbfd 0%, #f2f8fb 100%);
  border: 1px solid #dfebf2;
}

.freight-rule-editor {
  display: grid;
  gap: 14px;
  max-height: 1200px;
  opacity: 1;
  overflow: hidden;
  transition: max-height .26s var(--ease-smooth), opacity .18s var(--ease-smooth), transform .18s var(--ease-smooth), margin-top .18s var(--ease-smooth);
}

.freight-rule-card[data-expanded="0"] .freight-rule-editor {
  max-height: 0;
  opacity: 0;
  transform: translateY(-4px);
  margin-top: -4px;
  pointer-events: none;
}

.freight-rule-card[data-expanded="0"] {
  gap: 12px;
}

.freight-rule-card[data-expanded="1"] {
  border-color: #b9dcef;
  box-shadow: 0 20px 42px rgba(14, 165, 233, 0.10);
}

.toggle-rule-editor {
  background: #f4faff;
  color: #0c4a6e;
  border-color: #cfe4f5;
}

.toggle-rule-editor:hover {
  background: #e6f4ff;
  border-color: #9bc8e7;
}

.duplicate-shipping-rule {
  background: #f8fafc;
  color: #334155;
  border-color: #d7dee6;
}

.duplicate-shipping-rule:hover {
  background: #f1f5f9;
  border-color: #bfcbd8;
}

.freight-rule-overview span {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  color: #4a6779;
}

.freight-rule-overview strong {
  color: #163d52;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

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

.freight-rule-grid-secondary {
  padding-top: 2px;
}

.freight-field {
  display: grid !important;
  gap: 7px;
  font-size: 12px !important;
  font-weight: 700;
  color: #4f6d80 !important;
  letter-spacing: 0.01em;
}

.freight-field input,
.freight-field select {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  border: 1px solid #d5e4ec;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.freight-field-sm { grid-column: span 2; }
.freight-field-lg { grid-column: span 3; }
.freight-field-xl { grid-column: span 6; }

.freight-field-check {
  align-content: end;
}

.freight-field-check input {
  width: 22px;
  min-height: 22px;
  margin-top: 10px;
}

.freight-check {
  width: 18px;
  min-height: 18px;
  accent-color: var(--brand);
}

.btn-mini {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 12px;
}

.freight-row-new {
  border-color: #b6e6c7;
  background:
    radial-gradient(circle at top right, rgba(34, 197, 94, 0.10), transparent 24%),
    linear-gradient(180deg, #f4fff7 0%, #ffffff 100%);
}

.result-box {
  min-height: 320px;
  border: 1px dashed #d1d5db;
  border-radius: 14px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.6;
  background: #f9fafb;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}

.result-box:not(.empty) {
  border-style: solid;
  border-color: #9ddff5;
  box-shadow: inset 0 0 0 1px rgba(6, 182, 212, 0.07);
  background: linear-gradient(180deg, #f2fdff 0%, #ffffff 36%);
}

.result-box.result-updated {
  animation: resultPop .28s var(--ease-smooth);
}

.result-box.empty {
  color: #6b7280;
  display: grid;
  place-items: center;
}

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

.kv {
  background: #fff;
  border: 1px solid #d4e7f1;
  border-radius: 10px;
  padding: 10px;
  transition: transform .15s var(--ease-smooth), box-shadow .15s var(--ease-smooth), border-color .15s;
}

.kv:hover {
  transform: translateY(-1px);
  border-color: #8fd5eb;
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.09);
}

.kv.result-changed {
  border-color: #f7c97c;
  background: linear-gradient(180deg, #fffaf0 0%, #ffffff 100%);
  box-shadow: 0 10px 20px rgba(245, 158, 11, 0.14);
}

.kv strong { display: block; color: #111827; font-size: 16px; margin-top: 4px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal.hidden { display: none; }

.modal-dialog {
  width: min(760px, 100%);
  animation: modalIn .22s var(--ease-smooth);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid #e5e7eb;
}

.modal-body { padding: 16px 18px 20px; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: #f3f4f6;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.toolbar input[type="text"] { min-width: 280px; flex: 1; }

.table-wrap {
  overflow: auto;
  border: 1px solid #d2e7f3;
  border-radius: 12px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
}

th, td {
  border-bottom: 1px solid #f1f5f9;
  padding: 10px;
  text-align: left;
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
}

tr:hover td { background: #f9fbff; }

.tag-positive { color: #15803d; font-weight: 700; }
.tag-negative { color: #dc2626; font-weight: 700; }

.diff-preview {
  margin-top: 14px;
  border: 1px solid #dbeafe;
  background: #f8fbff;
  border-radius: 12px;
  padding: 12px;
}

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

.diff-preview.hidden { display: none; }

.diff-preview h3 {
  margin: 0;
  font-size: 14px;
}

.diff-preview-body {
  display: grid;
  gap: 6px;
}

.diff-row {
  font-size: 13px;
  color: #1f2937;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 6px 8px;
}

.field-changed {
  border-color: #f59e0b !important;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2) !important;
  background: #fffaf0;
}

.field-changed:focus {
  border-color: #f59e0b !important;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.24) !important;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes resultPop {
  from {
    transform: translateY(2px);
    opacity: 0.85;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 980px) {
  .login-layout { grid-template-columns: 1fr; max-width: 640px; }
  .grid-two { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .app-header { flex-direction: column; align-items: flex-start; }
  .config-shell { grid-template-columns: 1fr; }
  .config-sidebar { position: static; }
  .config-card-grid { grid-template-columns: 1fr; }
  .freight-config-head { flex-direction: column; }
  .freight-tools { min-width: 100%; }
  .freight-tools select,
  .freight-tools input[type="search"] { min-width: 100%; }
  .freight-rule-actions { width: 100%; }
  .freight-rule-actions .btn { flex: 1; }
  .freight-rule-grid { grid-template-columns: 1fr 1fr; }
  .freight-field-sm,
  .freight-field-lg,
  .freight-field-xl { grid-column: span 1; }
  .freight-rule-overview { flex-direction: column; gap: 8px; }
}
