:root {
  --orange: #ff6a00;
  --orange-dark: #e85f00;
  --dark: #1c1c1e;
  --ink: #222;
  --muted: #888;
  --line: #e4e4e7;
  --bg: #f4f4f5;
  --green: #16a34a;
  --red: #dc2626;
  --blue: #2563eb;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
code { background: #eee; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
a { color: var(--blue); }

/* ---- Top bar ---- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--dark); color: #fff; padding: 0 24px; height: 56px;
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  background: var(--orange); color: #fff; font-weight: 800; letter-spacing: .5px;
  padding: 3px 8px; border-radius: 4px; font-size: 15px;
}
.logo.big { font-size: 26px; padding: 8px 14px; }
.brand-name { font-weight: 600; }
#nav-links { display: flex; gap: 6px; }
#nav-links button {
  background: none; border: none; color: #cfcfcf; padding: 8px 14px; cursor: pointer;
  font-size: 14px; border-radius: 6px;
}
#nav-links button:hover { color: #fff; background: rgba(255,255,255,.08); }
#nav-links button.active { color: #fff; font-weight: 600; }
.user-box { display: flex; align-items: center; gap: 12px; }
.channel-pill { background: rgba(255,255,255,.12); padding: 4px 10px; border-radius: 20px; font-size: 12px; }
.link-btn { background: none; border: none; color: var(--orange); cursor: pointer; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }

/* ---- Buttons ---- */
.btn {
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 14px; cursor: pointer; font-size: 13px; color: var(--ink);
}
.btn:hover { border-color: #bbb; }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--orange-dark); }
.btn.block { width: 100%; padding: 11px; font-size: 15px; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Layout ---- */
.container { max-width: 1280px; margin: 0 auto; padding: 24px; }
.view { min-height: calc(100vh - 56px); }

/* ---- Login ---- */
.login-view { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg,#fafafa,#ececec); }
.login-card { background: #fff; padding: 40px; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.08); width: 380px; }
.login-logo { text-align: center; margin-bottom: 14px; }
.login-card h1 { text-align: center; margin: 0; font-size: 22px; }
.login-card > p.muted { text-align: center; margin-top: 4px; }
#login-form { margin-top: 22px; display: flex; flex-direction: column; gap: 14px; }
#login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #555; }
#login-form input { padding: 10px; border: 1px solid var(--line); border-radius: 7px; font-size: 14px; }
#login-form input:focus { outline: none; border-color: var(--orange); }
.error-msg { color: var(--red); font-size: 13px; min-height: 18px; }
.login-hints { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line); font-size: 12px; color: #666; }
.login-hints ul { margin: 8px 0 0; padding-left: 18px; line-height: 1.9; }

/* ---- Tabs ---- */
.tabs, .shop-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.shop-tabs { border: none; margin: 0; }
.tab { background: none; border: none; padding: 11px 18px; cursor: pointer; font-size: 14px; color: #666; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--orange); border-bottom-color: var(--orange); font-weight: 600; }

/* ---- Panels / tables ---- */
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 18px; }
.head-actions { display: flex; gap: 8px; }
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.data-table th { text-align: left; padding: 12px 14px; background: #fafafa; font-size: 12px; color: #666; text-transform: uppercase; letter-spacing: .3px; border-bottom: 1px solid var(--line); }
.data-table td { padding: 12px 14px; border-bottom: 1px solid #f0f0f0; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafafa; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.all      { background: #eef2ff; color: #4338ca; }
.badge.domestic { background: #fff7ed; color: #c2410c; }
.badge.overseas { background: #ecfdf5; color: #047857; }
.badge.on_sale  { background: #ecfdf5; color: var(--green); }
.badge.closed   { background: #fef2f2; color: var(--red); }
.badge.active   { background: #ecfdf5; color: var(--green); }
.badge.disabled { background: #f3f4f6; color: #6b7280; }
.region-badge { font-weight: 700; padding: 5px 14px; border-radius: 20px; font-size: 13px; }
.region-badge.domestic { background: #fff7ed; color: #c2410c; }
.region-badge.overseas { background: #ecfdf5; color: #047857; }

.bulk-result { background: #f0fdf4; border: 1px solid #bbf7d0; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.bulk-result.has-error { background: #fffbeb; border-color: #fde68a; }
.bulk-result ul { margin: 6px 0 0; padding-left: 18px; color: var(--red); }

/* ---- SKU grid (shop) ---- */
.sku-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 20px; padding-bottom: 90px; }
.sku-card { background: #fff; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.06); overflow: hidden; display: flex; flex-direction: column; }
.sku-card .loc { color: var(--orange); font-weight: 700; padding: 12px 16px 0; }
.sku-card .body { padding: 14px 16px; display: flex; gap: 14px; }
.sku-thumb { width: 110px; height: 110px; flex-shrink: 0; background: #eee; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #aaa; font-size: 11px; text-align: center; }
.sku-thumb-img { width: 110px; height: 110px; flex-shrink: 0; border-radius: 8px; object-fit: cover; background: #eee; }
.tbl-thumb { width: 34px; height: 34px; border-radius: 5px; object-fit: cover; vertical-align: middle; margin-right: 8px; }
.img-upload { display: flex; align-items: center; gap: 10px; margin-top: 5px; }
.img-preview { width: 64px; height: 64px; border: 1px solid var(--line); border-radius: 8px; background: #f4f4f5; display: flex; align-items: center; justify-content: center; color: #bbb; font-size: 10px; overflow: hidden; flex-shrink: 0; }
.img-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---- SKU carousel (slideshow) ---- */
.sku-carousel { position: relative; width: 100%; height: 180px; background: #f1f1f3; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.carousel-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.carousel-empty { color: #bbb; font-size: 12px; }
.carousel-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%; border: none; background: rgba(0,0,0,.4); color: #fff; cursor: pointer; font-size: 15px; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .15s; }
.sku-card:hover .carousel-nav { opacity: 1; }
.carousel-nav:hover { background: rgba(0,0,0,.62); }
.carousel-nav.prev { left: 8px; } .carousel-nav.next { right: 8px; }
.carousel-dots { position: absolute; bottom: 8px; left: 0; right: 0; display: flex; gap: 5px; justify-content: center; }
.carousel-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.55); cursor: pointer; box-shadow: 0 0 2px rgba(0,0,0,.4); }
.carousel-dot.active { background: #fff; }
.carousel-count { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.5); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 10px; }
.sku-buy { padding: 12px 16px 4px; }
.sku-buy .config-toggle { margin: 2px 0 10px; }
.unit-pill { display: inline-block; border: 1px solid var(--orange); color: var(--orange); background: #fff7ed; padding: 5px 14px; border-radius: 6px; font-size: 13px; font-weight: 600; }

/* ---- Country picker ---- */
.cpick { border: 1px solid var(--line); border-radius: 8px; margin-top: 5px; }
.cpick-search { width: 100%; border: none; border-bottom: 1px solid var(--line); padding: 8px 10px; border-radius: 8px 8px 0 0; box-sizing: border-box; }
.cpick-search:focus { outline: none; }
.cpick-list { max-height: 170px; overflow: auto; padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.cpick-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 16px; padding: 4px 10px; font-size: 12px; cursor: pointer; user-select: none; }
.cpick-chip input { display: none; }
.cpick-chip.on { background: var(--orange); border-color: var(--orange); color: #fff; }
.cpick-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; border-top: 1px solid var(--line); font-size: 12px; color: #666; }
.cpick-bar a { cursor: pointer; color: var(--blue); }
.cpick[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.country-badges { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.country-badge { background: #eef2ff; color: #4338ca; border-radius: 5px; padding: 1px 6px; font-size: 11px; }
.country-badge.all { background: #ecfdf5; color: #047857; }
.allco-row { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; }
.allco-row input { width: auto; }

/* ---- Multi-image form thumbnails ---- */
.form-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 5px; align-items: center; }
.form-img { position: relative; width: 56px; height: 56px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.form-img img { width: 100%; height: 100%; object-fit: cover; }
.form-img-x { position: absolute; top: 1px; right: 1px; width: 16px; height: 16px; border: none; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; line-height: 1; cursor: pointer; padding: 0; }
.img-hint { font-size: 11px; color: var(--muted); margin-left: 2px; width: 100%; }
.region-badge { background: #eef2ff; color: #4338ca; }

/* ---- Price tiers (常规/特价) ---- */
.shop-toolbar-left { display: flex; align-items: center; gap: 16px; }
.tier-tabs { display: inline-flex; gap: 8px; }
.tier-tab { border: 1px solid var(--line); background: #fff; padding: 7px 18px; border-radius: 20px; cursor: pointer; font-size: 13px; color: #555; }
.tier-tab:hover { border-color: #bbb; }
.tier-tab.active { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 600; }
.tier-tab.special.active { background: var(--red); border-color: var(--red); }
#sku-grid { padding-bottom: 90px; }
#sku-grid .sku-grid { padding-bottom: 0; }
.tier-badge { float: right; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 10px; letter-spacing: .5px; }
.badge.tier-special { background: #fef2f2; color: var(--red); }

/* ---- Checkout ---- */
.co-summary { background: #fafafa; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.co-section-title { font-weight: 700; font-size: 14px; margin: 16px 0 8px; }
.co-section-title:first-child { margin-top: 0; }
.co-line { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid #f0f0f0; font-size: 13px; }
.co-line:last-of-type { border-bottom: none; }
.co-total { text-align: right; margin-top: 8px; font-size: 15px; }
.co-total b { color: var(--orange); }
.order-ship { font-size: 12px; color: #555; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); line-height: 1.7; }
.sku-config .config-toggle { display: flex; gap: 6px; margin: 4px 0 10px; }
.sku-config .config-toggle button { border: 1px solid var(--line); background: #fff; padding: 5px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.sku-config .config-toggle button.active { border-color: var(--orange); color: var(--orange); font-weight: 600; }
.qty-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.qty-row button { width: 30px; height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; font-size: 16px; color: var(--orange); }
.qty-row input { width: 64px; text-align: center; padding: 6px; border: 1px solid var(--line); border-radius: 6px; }
.sku-price { margin-top: 8px; font-size: 13px; color: #555; }
.sku-price b { color: var(--ink); font-size: 15px; }
.sku-title { font-weight: 700; padding: 0 16px; line-height: 1.4; min-height: 40px; }
.sku-meta { padding: 10px 16px 16px; font-size: 12px; color: #666; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.sku-meta span b { color: #333; }
.restriction-tag { position: relative; }

/* ---- Cart bar ---- */
.cart-bar { position: fixed; bottom: 0; left: 0; right: 0; background: #fff7ed; border-top: 1px solid #fed7aa; padding: 14px 32px; display: flex; align-items: center; justify-content: flex-end; gap: 24px; z-index: 40; box-shadow: 0 -2px 12px rgba(0,0,0,.05); }
.cart-total b { color: var(--orange); font-size: 16px; }

/* ---- Orders ---- */
.orders-list { display: flex; flex-direction: column; gap: 14px; }
.order-card { background: #fff; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.05); padding: 16px 20px; }
.order-card .order-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid #f0f0f0; flex-wrap: wrap; }
.order-card .order-no { font-weight: 700; }
.order-head-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.order-actions { display: inline-flex; align-items: center; gap: 8px; }
.order-status-sel { padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; background: #fff; cursor: pointer; }
.badge.st-submitted { background: #fff7ed; color: #c2410c; }
.badge.st-confirmed { background: #eff6ff; color: #1d4ed8; }
.badge.st-shipped   { background: #ecfdf5; color: #047857; }
.badge.st-cancelled { background: #f3f4f6; color: #6b7280; }
.order-items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.order-items-table td, .order-items-table th { padding: 6px 8px; text-align: left; border-bottom: 1px solid #f5f5f5; }
.order-items-table th { color: #888; font-weight: 500; font-size: 12px; }

/* ---- Shop toolbar ---- */
.shop-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 12px; width: 460px; max-width: 92vw; max-height: 90vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; }
#modal-body { padding: 22px; }
#modal-body label { display: block; margin-bottom: 14px; font-size: 13px; color: #555; }
#modal-body input, #modal-body select { width: 100%; padding: 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 14px; margin-top: 5px; }
#modal-body input:focus, #modal-body select:focus { outline: none; border-color: var(--orange); }
.form-row { display: flex; gap: 12px; }
.form-row label { flex: 1; }

/* ---- Language switch ---- */
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: #fff; }
.lang-switch button { border: none; background: none; padding: 4px 12px; cursor: pointer; font-size: 12px; color: #666; line-height: 1.6; }
.lang-switch button.active { background: var(--orange); color: #fff; font-weight: 600; }
#topbar .lang-switch { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.22); }
#topbar .lang-switch button { color: #cfcfcf; }
#topbar .lang-switch button.active { background: var(--orange); color: #fff; }
.login-lang { position: absolute; top: 22px; right: 26px; }

/* ---- Toast ---- */
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--dark); color: #fff; padding: 12px 22px; border-radius: 8px; z-index: 200; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
