:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #64717f;
  --line: #dfe5e9;
  --soft: #f5f7f8;
  --surface: #ffffff;
  --green: #147d64;
  --green-dark: #0e5e4b;
  --green-soft: #e9f5f1;
  --coral: #d86149;
  --coral-soft: #fff0ec;
  --gold: #9a6a18;
  --gold-soft: #fff8e6;
  --blue: #2e6fa3;
  --blue-soft: #edf5fb;
  --shadow: 0 12px 32px rgba(26, 40, 52, 0.08);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; min-width: 320px; background: #eef2f3; color: var(--ink); }
button, input, select { font: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(46, 111, 163, 0.22);
  outline-offset: 1px;
}

.app-header {
  height: 72px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; background: var(--green); border-radius: 7px; }
.brand-mark img { width: 22px; filter: brightness(0) invert(1); }
.brand h1 { margin: 0; font-size: 18px; line-height: 1.25; letter-spacing: 0; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid #b9dcd2;
  border-radius: 16px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 600;
}
.status-dot { width: 8px; height: 8px; background: var(--gold); border-radius: 50%; }
.system-status.ready .status-dot { background: var(--green); }
.system-status.error { background: var(--coral-soft); border-color: #f0c3b8; color: #9e3f2d; }
.system-status.error .status-dot { background: var(--coral); }

.app-shell { width: min(1500px, 100%); min-height: 100vh; margin: 0 auto; padding: 20px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.calculator-panel, .results-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.calculator-panel { padding: 22px; }
.results-panel { min-height: 0; padding: 22px; position: static; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
.section-heading h2, .dialog-heading h2 { margin: 2px 0 0; font-size: 22px; letter-spacing: 0; }
.eyebrow { margin: 0; color: var(--green); font-size: 11px; font-weight: 800; }
.icon-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}
.icon-button:hover { background: var(--soft); }
.icon-button img { width: 17px; }

form { display: grid; gap: 20px; }
fieldset { margin: 0; padding: 0 0 20px; border: 0; border-bottom: 1px solid var(--line); min-width: 0; }
legend { margin: 0 0 14px; padding: 0; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
legend img { width: 17px; opacity: 0.72; }
.fieldset-heading { min-height: 36px; margin-bottom: 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.fieldset-heading legend { margin: 8px 0 0; }
.field-grid { display: grid; gap: 14px; }
.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; min-width: 0; }
.field > span { color: #4e5a65; font-size: 12px; font-weight: 600; }
.required-mark { color: var(--coral); font-style: normal; }
input, select {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  border: 1px solid #cfd7dc;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
input:hover, select:hover { border-color: #aebbc3; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(46, 111, 163, 0.11); outline: none; }

.secondary-button, .add-result-button {
  min-height: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #b8c5cb;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.secondary-button:hover, .add-result-button:hover { background: var(--soft); border-color: #94a6ae; }
.secondary-button img, .add-result-button img { width: 15px; }
.secondary-button.compact { min-width: 76px; font-size: 12px; }

.cart-list { display: grid; gap: 8px; }
.cart-item, .product-result {
  min-width: 0;
  padding: 11px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}
.product-thumb {
  width: 54px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: var(--thumb-color);
  overflow: hidden;
}
.product-thumb img { width: 100%; height: 100%; object-fit: cover; opacity: 1; }
.product-thumb img[src^="/icons/"] { width: 25px; height: 25px; object-fit: contain; opacity: 0.68; }
.product-copy { min-width: 0; display: grid; gap: 3px; }
.product-copy strong { font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.product-copy span { color: var(--muted); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.product-copy .unit-price { color: var(--ink); font-weight: 700; }
.product-variant-select { width: 100%; min-width: 0; height: 30px; padding: 0 7px; border: 1px solid #cfd7dc; border-radius: 5px; background: var(--surface); font-size: 11px; color: var(--ink); }
.line-total { min-width: 92px; display: grid; gap: 4px; text-align: right; }
.line-total strong { font-size: 13px; }
.line-total span { color: var(--muted); font-size: 11px; }
.cart-actions { display: flex; align-items: center; gap: 7px; }
.quantity-stepper { height: 34px; display: grid; grid-template-columns: 32px 34px 32px; align-items: center; border: 1px solid #cfd7dc; border-radius: 6px; overflow: hidden; }
.quantity-stepper button, .remove-button { height: 100%; border: 0; background: var(--surface); cursor: pointer; display: grid; place-items: center; }
.quantity-stepper button:hover { background: var(--soft); }
.quantity-stepper img, .remove-button img { width: 14px; }
.quantity-stepper span { text-align: center; font-size: 12px; font-weight: 700; }
.remove-button { width: 34px; height: 34px; border: 1px solid #efc7bf; border-radius: 6px; background: var(--coral-soft); }
.remove-button img { filter: invert(40%) sepia(35%) saturate(1250%) hue-rotate(325deg); }
.add-product-button {
  width: 100%;
  height: 40px;
  margin-top: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px dashed #9cb4ae;
  border-radius: 6px;
  background: #f8fbfa;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.add-product-button:hover { background: var(--green-soft); }
.add-product-button img { width: 15px; }
.cart-summary { margin-top: 12px; padding: 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; background: var(--soft); border-radius: 6px; }
.cart-summary div { min-width: 0; display: grid; gap: 5px; }
.cart-summary span { color: var(--muted); font-size: 10px; }
.cart-summary strong { font-size: 12px; overflow-wrap: anywhere; }
.cart-empty { min-height: 94px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 1px dashed #cbd4d9; border-radius: 7px; color: var(--muted); font-size: 12px; }
.cart-empty img { width: 23px; opacity: 0.55; }

.primary-button {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 7px;
  background: var(--green);
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}
.primary-button:hover { background: var(--green-dark); }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { opacity: 0.55; cursor: not-allowed; }
.primary-button img { width: 18px; filter: brightness(0) invert(1); }

.quote-time { color: var(--muted); font-size: 12px; }
.empty-state, .loading-state, .error-state { min-height: 510px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); }
.empty-state h3, .error-state h3 { margin: 18px 0 6px; color: var(--ink); font-size: 17px; }
.empty-state p, .error-state p { width: min(360px, 100%); margin: 0; line-height: 1.6; font-size: 13px; }
.empty-icon { width: 68px; height: 68px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); }
.empty-icon img { width: 32px; opacity: 0.72; }
.loading-state { gap: 8px; }
.loading-state strong { margin-top: 12px; color: var(--ink); }
.loading-state span { font-size: 12px; }
.spinner, .small-spinner { border: 3px solid #dce9e5; border-top-color: var(--green); border-radius: 50%; animation: spin 800ms linear infinite; }
.spinner { width: 34px; height: 34px; }
.small-spinner { width: 18px; height: 18px; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-state img { width: 36px; filter: invert(41%) sepia(76%) saturate(750%) hue-rotate(327deg); }

.selected-summary { padding: 20px; background: #172b29; color: white; border-radius: 8px; }
.summary-topline { display: flex; justify-content: space-between; align-items: center; }
.summary-label { color: #c8d6d3; font-size: 13px; }
.estimate-badge { padding: 4px 7px; border: 1px solid #53716c; border-radius: 4px; color: #b9dcd3; font-size: 10px; font-weight: 800; }
.total-line { margin-top: 10px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.total-line strong { max-width: 100%; overflow-wrap: anywhere; font-size: 28px; line-height: 1.15; letter-spacing: 0; }
.total-line span { color: #b9c8c5; font-size: 13px; font-weight: 700; }
.route-line { margin-top: 12px; color: #d5e0de; font-size: 13px; }
.route-separator { margin: 0 5px; color: #77918b; }
.customs-summary { margin-top: 16px; padding: 12px 14px; display: flex; align-items: flex-start; gap: 10px; border: 1px solid #cce6de; border-radius: 7px; background: var(--green-soft); color: var(--green-dark); }
.customs-summary img { width: 18px; margin-top: 1px; }
.customs-summary div { min-width: 0; display: grid; gap: 4px; }
.customs-summary strong { font-size: 13px; overflow-wrap: anywhere; }
.customs-summary span { font-size: 11px; line-height: 1.45; }
.customs-summary.unavailable { border-color: #efdaa5; background: var(--gold-soft); color: #735016; }
.customs-summary.unavailable img { filter: invert(40%) sepia(70%) saturate(650%) hue-rotate(356deg); }
.breakdown { margin-top: 16px; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.cost-row { min-height: 42px; padding: 9px 13px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.cost-row:last-child { border-bottom: 0; }
.cost-row span { color: var(--muted); }
.cost-row strong { text-align: right; }
.cost-row.total { background: var(--soft); font-weight: 700; }
.cost-row.total span { color: var(--ink); }
/* A breakdown line rather than a charge: the duty is already inside the shipping figure
   above, so this row is muted and never added to the total. */
.cost-row.memo strong { font-weight: 600; }
.cost-note { display: block; margin-top: 2px; font-size: 11px; line-height: 1.35; }
.subsection-heading { margin: 22px 0 10px; display: flex; align-items: center; justify-content: space-between; }
.subsection-heading h3, .evidence-title h3 { margin: 0; font-size: 14px; }
.subsection-heading span { color: var(--muted); font-size: 12px; }
.shipping-options { display: grid; gap: 8px; }
.shipping-option { width: 100%; min-height: 70px; padding: 12px; display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); text-align: left; cursor: pointer; }
.shipping-option:hover { border-color: #9ebeb5; }
.shipping-option.selected { border-color: var(--green); background: #f6fbf9; box-shadow: 0 0 0 2px rgba(20, 125, 100, 0.08); }
.radio-dot { width: 16px; height: 16px; border: 1px solid #aab6bd; border-radius: 50%; position: relative; }
.selected .radio-dot { border-color: var(--green); }
.selected .radio-dot::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--green); }
.option-name { display: block; overflow-wrap: anywhere; font-size: 13px; font-weight: 700; }
.option-meta { margin-top: 4px; display: block; color: var(--muted); font-size: 11px; }
.option-price { text-align: right; }
.option-price strong { display: block; font-size: 15px; }
.option-price span { color: var(--muted); font-size: 10px; }
.estimate-details { margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); }
.evidence-title { display: flex; align-items: center; gap: 8px; }
.evidence-title img { width: 16px; }
.estimate-details dl { margin: 12px 0 0; display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 8px 12px; font-size: 12px; }
.estimate-details dt { color: var(--muted); }
.estimate-details dd { margin: 0; overflow-wrap: anywhere; font-weight: 600; }
.notice { display: flex; align-items: flex-start; gap: 9px; padding: 11px 12px; border-radius: 6px; font-size: 12px; line-height: 1.5; }
.notice img { width: 16px; flex: 0 0 auto; margin-top: 1px; }
.info-notice { margin-top: 18px; background: var(--blue-soft); color: #315c7c; border: 1px solid #ccdfed; }

.product-dialog { width: min(650px, calc(100vw - 28px)); max-height: min(720px, calc(100vh - 36px)); padding: 22px; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 24px 80px rgba(23, 32, 42, 0.25); }
.product-dialog::backdrop { background: rgba(23, 32, 42, 0.52); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.search-box { height: 44px; margin-top: 18px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid #cfd7dc; border-radius: 6px; }
.search-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(46, 111, 163, 0.11); }
.search-box img { width: 17px; opacity: 0.62; }
.search-box input { height: 40px; padding: 0; border: 0; box-shadow: none; }
.product-results { min-height: 190px; max-height: 500px; margin-top: 12px; display: grid; gap: 8px; overflow-y: auto; }
.product-result { grid-template-columns: 54px minmax(0, 1fr) auto; }
.add-result-button { min-width: 94px; font-size: 12px; color: var(--green-dark); border-color: #aad0c5; }
.product-loading, .product-empty { min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 12px; }
.product-loading { flex-direction: row; }
.product-empty img { width: 25px; opacity: 0.55; }

.hidden { display: none !important; }

@media (max-width: 1040px) {
  .app-shell { grid-template-columns: 1fr; max-width: 760px; }
  .results-panel { min-height: 560px; }
}

@media (max-width: 640px) {
  .app-shell { padding: 12px; gap: 12px; }
  .calculator-panel, .results-panel { padding: 17px; }
  .two-cols { grid-template-columns: 1fr; }
  .section-heading h2, .dialog-heading h2 { font-size: 19px; }
  .cart-item { grid-template-columns: 48px minmax(0, 1fr); }
  .product-thumb { width: 48px; height: 56px; }
  .line-total, .cart-actions { grid-column: 2; justify-self: stretch; text-align: left; }
  .cart-actions { justify-content: space-between; }
  .cart-summary { grid-template-columns: 1fr; }
  .cart-summary div { grid-template-columns: 1fr auto; align-items: center; }
  .total-line strong { font-size: 22px; }
  .cost-row { align-items: flex-start; }
  .shipping-option { grid-template-columns: 18px minmax(0, 1fr); }
  .option-price { grid-column: 2; text-align: left; display: flex; align-items: baseline; gap: 6px; }
  .product-dialog { padding: 17px; }
  .product-result { grid-template-columns: 48px minmax(0, 1fr); }
  .product-result .add-result-button { grid-column: 2; width: 100%; }
}

/* ── refactor: origin line, warnings and the submit row ───────────────────── */

.origin-line { color: #a9bdba; font-size: 11px; }

.notice.warn-notice {
  margin-top: 14px;
  border: 1px solid #efdaa5;
  background: var(--gold-soft);
  color: #735016;
}
.notice.warn-notice img { filter: invert(40%) sepia(70%) saturate(650%) hue-rotate(356deg); }

/* Inline split-shipment warning shown while the basket is being built */
.cart-weight-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #efdaa5;
  border-radius: 6px;
  background: var(--gold-soft);
  color: #735016;
  font-size: 12px;
  line-height: 1.5;
}
.cart-weight-hint img { width: 15px; flex: 0 0 auto; margin-top: 1px; filter: invert(40%) sepia(70%) saturate(650%) hue-rotate(356deg); }

