:root {
  color-scheme: light;
  --ink: #172126;
  --muted: #68777d;
  --line: #dce4e4;
  --surface: #ffffff;
  --surface-soft: #f5f8f7;
  --teal: #0c6b62;
  --teal-dark: #084f49;
  --teal-soft: #e4f3ef;
  --orange: #ef7f3f;
  --orange-soft: #fff0e6;
  --danger: #b94343;
  --danger-soft: #fff0f0;
  --shadow: 0 14px 40px rgba(21, 50, 48, 0.08);
  --radius: 18px;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 4% 0%, rgba(12, 107, 98, 0.08), transparent 28rem),
    #f7f9f8;
  min-height: 100vh;
}

button, input, select, textarea { font: inherit; }

a { color: inherit; }

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid rgba(210, 220, 219, 0.9);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-logo-frame {
  position: relative;
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  overflow: hidden;
  border-radius: 12px;
  background: white;
}
.brand-logo { position: absolute; width: 124px; max-width: none; left: -31px; top: -27px; }

.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: 0.01em; white-space: nowrap; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }

nav { display: flex; gap: 8px; }
nav a {
  padding: 10px 14px;
  text-decoration: none;
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
}
nav a:hover, nav a:focus-visible { background: var(--surface-soft); color: var(--ink); }
nav a.active { background: var(--teal-soft); color: var(--teal-dark); font-weight: 700; }

.page-shell { max-width: 1180px; margin: 0 auto; padding: 48px 24px 72px; }

.intro-row {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 32px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(28px, 4vw, 42px); line-height: 1.18; letter-spacing: -0.035em; }
.intro-row > div > p:last-child { margin-bottom: 0; color: var(--muted); font-size: 15px; }

.rule-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border: 1px solid #cfe3df;
  border-radius: 999px;
  color: var(--teal-dark);
  background: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
  font-size: 13px;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #20a77c; box-shadow: 0 0 0 4px #dff5ed; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.8fr); gap: 20px; align-items: start; }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.calculator-panel { padding: 28px; }
.product-panel { padding: 24px; position: sticky; top: 92px; }

.panel-heading { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 24px; }
.panel-heading h2 { margin-bottom: 4px; font-size: 19px; }
.panel-heading p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.compact-heading { margin-bottom: 18px; }
.product-panel-heading { position: relative; padding-right: 84px; }
.parameter-edit-button {
  position: absolute;
  top: 0;
  right: 0;
  padding: 7px 10px;
  border: 1px solid #bcdad4;
  border-radius: 9px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
}
.parameter-edit-button:hover, .parameter-edit-button:focus-visible { border-color: var(--teal); }
.parameter-edit-button:disabled { cursor: default; opacity: 0.72; }

.step-number {
  min-width: 35px;
  padding-top: 3px;
  color: var(--orange);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 800;
  font-size: 13px;
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.field-wide { grid-column: 1 / -1; }
.field { display: grid; gap: 7px; }
.field > span { color: #46555a; font-size: 13px; font-weight: 700; }
.field b { color: var(--orange); }

input, select, textarea {
  width: 100%;
  border: 1px solid #cfd9d8;
  border-radius: 11px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(12, 107, 98, 0.12); }
input::placeholder, textarea::placeholder { color: #9aa6aa; }

.product-combobox { position: relative; }
.product-options {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  box-shadow: 0 18px 38px rgba(22, 48, 48, 0.16);
}
.product-option {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 11px 13px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: white;
  text-align: left;
  cursor: pointer;
}
.product-option:last-child { border-bottom: 0; }
.product-option:hover, .product-option:focus-visible, .product-option.active { background: var(--teal-soft); outline: none; }
.product-option strong { font-size: 13px; }
.product-option small { color: var(--muted); font-size: 11px; }
.product-option-empty { padding: 18px; color: var(--muted); text-align: center; font-size: 13px; }

.primary-button, .secondary-button, .danger-button {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 750;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.primary-button {
  width: 100%;
  margin-top: 22px;
  padding: 13px 17px;
  display: flex;
  justify-content: center;
  gap: 10px;
  color: white;
  background: var(--teal);
  box-shadow: 0 10px 22px rgba(12, 107, 98, 0.18);
}

.primary-button:hover { background: var(--teal-dark); transform: translateY(-1px); }
.primary-button:disabled { opacity: 0.55; cursor: wait; transform: none; }
.secondary-button { display: inline-flex; align-items: center; justify-content: center; padding: 9px 13px; color: var(--teal-dark); background: var(--teal-soft); text-decoration: none; }
.secondary-button:disabled { opacity: 0.55; cursor: wait; }
.danger-button { padding: 9px 13px; color: var(--danger); background: var(--danger-soft); }

.form-message { min-height: 20px; margin: 10px 0 -8px; color: var(--danger); font-size: 13px; text-align: center; }

.supplement-panel {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #f4c6a8;
  border-radius: 13px;
  background: var(--orange-soft);
}
.supplement-panel strong { color: #8b441c; }
.supplement-panel p { margin: 4px 0 14px; color: #8c634d; font-size: 12px; }
.compact-grid { gap: 12px; }

.product-summary { min-height: 220px; }
.empty-summary { display: grid; place-items: center; align-content: center; gap: 12px; color: var(--muted); text-align: center; }
.empty-summary p { max-width: 240px; margin-bottom: 0; font-size: 13px; line-height: 1.7; }
.empty-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; background: var(--surface-soft); color: #8ea09e; font-size: 25px; }

.product-name { margin-bottom: 5px; font-size: 18px; line-height: 1.45; }
.product-code { margin-bottom: 17px; color: var(--muted); font-size: 12px; }
.data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.data-item { padding: 11px; border-radius: 11px; background: var(--surface-soft); }
.data-item span, .data-item strong { display: block; }
.data-item span { color: var(--muted); font-size: 11px; }
.data-item strong { margin-top: 4px; font-size: 14px; word-break: break-word; }
.missing-badge { display: inline-block; margin-top: 14px; padding: 6px 9px; border-radius: 8px; color: #914f29; background: var(--orange-soft); font-size: 12px; }
.parameter-editor { margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.parameter-editor-title { display: grid; gap: 3px; margin-bottom: 14px; }
.parameter-editor-title strong { font-size: 14px; }
.parameter-editor-title small { color: var(--muted); font-size: 10px; line-height: 1.5; }
.parameter-editor .form-grid { gap: 10px; }
.parameter-editor .field > span { font-size: 11px; }
.parameter-editor input { padding: 9px 10px; font-size: 12px; }
.parameter-editor .form-message { margin: 7px 0 0; text-align: left; }
.parameter-editor-actions { display: flex; gap: 8px; margin-top: 12px; }
.parameter-editor-actions .secondary-button { flex: 1; }
.plain-button {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: white;
  cursor: pointer;
}
.plain-button:hover, .plain-button:focus-visible { color: var(--ink); border-color: #b8c5c3; }

.results-section { margin-top: 32px; }
.results-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; padding: 0 4px; }
.results-heading h2 { margin-bottom: 0; font-size: 25px; }
.result-context { color: var(--muted); font-size: 13px; }

.shipment-summary { display: grid; grid-template-columns: minmax(210px, 0.8fr) minmax(0, 2fr); gap: 12px; margin-top: 18px; padding: 12px; border: 1px solid #a9d9cc; border-radius: var(--radius); background: linear-gradient(135deg, #f1fbf8, #ffffff); box-shadow: 0 10px 28px rgba(12, 107, 98, 0.08); }
.shipment-volume-lead { display: flex; flex-direction: column; justify-content: center; min-height: 100px; padding: 18px 20px; border-radius: 14px; color: white; background: var(--teal-dark); }
.shipment-volume-lead > span { font-size: 12px; opacity: 0.82; }
.shipment-volume-lead div { display: flex; align-items: baseline; gap: 7px; margin-top: 7px; }
.shipment-volume-lead strong { font-size: clamp(32px, 4vw, 46px); line-height: 1; }
.shipment-volume-lead b { font-size: 13px; }
.shipment-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.shipment-metrics > div { display: flex; flex-direction: column; justify-content: center; padding: 12px 14px; border-radius: 11px; background: rgba(255, 255, 255, 0.9); }
.shipment-metrics span { color: var(--muted); font-size: 10px; }
.shipment-metrics strong { margin-top: 4px; font-size: 14px; word-break: break-word; }
.shipment-metrics small { margin-top: 2px; color: var(--muted); font-size: 10px; }

.result-group { margin-top: 18px; padding: 23px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,0.78); }
.group-title { display: flex; align-items: center; gap: 12px; margin-bottom: 17px; }
.group-title h3 { margin-bottom: 2px; font-size: 17px; }
.group-title p { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.group-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; font-weight: 800; }
.express-icon { color: #126399; background: #e6f3fb; }
.freight-icon { color: #9c521d; background: var(--orange-soft); }

.quote-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 13px; }
.result-placeholder { grid-column: 1 / -1; padding: 25px; border: 1px dashed #ccd7d5; border-radius: 13px; color: var(--muted); text-align: center; font-size: 13px; }

.quote-card { position: relative; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.quote-card.cheapest { border-color: #83cbb8; box-shadow: 0 12px 26px rgba(12, 107, 98, 0.1); }
.quote-card.unavailable { background: #fafbfb; box-shadow: none; }
.best-tag { position: absolute; top: -9px; right: 12px; padding: 4px 8px; border-radius: 999px; color: white; background: var(--teal); font-size: 10px; font-weight: 800; }
.quote-title { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.quote-title h4 { margin: 0; font-size: 15px; }
.region-tag { padding: 4px 7px; border-radius: 7px; color: var(--muted); background: var(--surface-soft); font-size: 10px; }
.quote-price { margin: 18px 0 15px; }
.quote-price strong { color: var(--teal-dark); font-size: 30px; line-height: 1; }
.quote-price span { margin-left: 3px; color: var(--muted); font-size: 12px; }
.quote-notice { margin: -4px 0 14px; padding: 9px 11px; border: 1px solid #f1cf86; border-radius: 9px; color: #7a4a00; background: #fff8e8; font-size: 11px; line-height: 1.55; }
.quote-subprice { margin-top: 6px; color: var(--muted); font-size: 11px; }
.quote-facts { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.quote-fact { padding: 8px; border-radius: 9px; background: var(--surface-soft); }
.quote-fact span, .quote-fact strong { display: block; }
.quote-fact span { color: var(--muted); font-size: 10px; }
.quote-fact strong { margin-top: 3px; font-size: 12px; }
.quote-card details { margin-top: 13px; border-top: 1px solid var(--line); padding-top: 11px; }
.quote-card summary { cursor: pointer; color: var(--teal-dark); font-size: 12px; font-weight: 700; }
.quote-card ul { margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: 11px; line-height: 1.65; }
.unavailable-reason { margin: 18px 0 0; min-height: 55px; color: var(--muted); font-size: 13px; line-height: 1.6; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); padding: 11px 16px; border-radius: 10px; color: white; background: #26383b; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: 160ms ease; z-index: 20; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.admin-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.admin-sidebar { padding: 13px; position: sticky; top: 92px; }
.tab-button { width: 100%; padding: 11px 12px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; text-align: left; cursor: pointer; }
.tab-button.active { color: var(--teal-dark); background: var(--teal-soft); font-weight: 750; }
.admin-content { padding: 25px; min-width: 0; }
.admin-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.admin-toolbar h2 { margin-bottom: 3px; }
.admin-toolbar p { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.admin-toolbar-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.import-summary { margin: -6px 0 14px; color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); background: var(--surface-soft); font-size: 11px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfc; }
.text-button { border: 0; color: var(--teal); background: transparent; cursor: pointer; font-weight: 700; }
.status-chip { padding: 3px 7px; border-radius: 999px; color: var(--teal-dark); background: var(--teal-soft); font-size: 10px; }
.status-chip.off { color: var(--muted); background: #edf0f0; }
.editor { margin-top: 20px; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.editor h3 { margin-bottom: 15px; }
.editor-actions { display: flex; gap: 10px; margin-top: 18px; }
.editor-actions .primary-button { width: auto; margin-top: 0; }
.tier-list { display: grid; gap: 8px; margin-top: 10px; }
.tier-row { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; align-items: end; }
.hidden { display: none !important; }

@media (max-width: 860px) {
  .workspace-grid, .admin-layout { grid-template-columns: 1fr; }
  .product-panel, .admin-sidebar { position: static; }
  .admin-sidebar { display: flex; overflow-x: auto; }
  .tab-button { width: auto; white-space: nowrap; }
  .intro-row { align-items: flex-start; flex-direction: column; }
  .admin-toolbar { align-items: flex-start; flex-direction: column; }
  .admin-toolbar-actions { justify-content: flex-start; }
}

@media (max-width: 600px) {
  .topbar { height: auto; padding: 12px 16px; align-items: flex-start; }
  .brand-logo-frame { width: 48px; height: 48px; flex-basis: 48px; }
  .brand-logo { width: 94px; left: -24px; top: -21px; }
  .brand strong { max-width: 150px; white-space: normal; font-size: 12px; line-height: 1.25; }
  .brand small { display: none; }
  nav a { padding: 9px; font-size: 12px; }
  .page-shell { padding: 30px 14px 48px; }
  .calculator-panel, .product-panel, .result-group, .admin-content { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .results-heading { align-items: flex-start; flex-direction: column; }
  .shipment-summary { grid-template-columns: 1fr; }
  .shipment-metrics { grid-template-columns: 1fr 1fr; }
  .quote-grid { grid-template-columns: 1fr; }
  .tier-row { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

body.member #edit-product-button { display: none !important; }
nav { flex-wrap: wrap; }
