:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --navy: #1b365d;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --exact-bg: #dcfce7;
  --exact-fg: #166534;
  --sim-bg: #fef3c7;
  --sim-fg: #92400e;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* Login screen */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1b365d 0%, #2b548a 100%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 14px;
  padding: 36px 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.login-card h1 {
  margin: 0 0 6px;
  font-size: 21px;
  color: var(--navy);
}
.login-card p.sub {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Top Navbar */
.navbar {
  background: var(--navy);
  color: #fff;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.14);
}
.nav-brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-tabs {
  display: flex;
  gap: 6px;
}
.nav-tab {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.78);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-tab:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.nav-tab.active { background: #fff; color: var(--navy); font-weight: 700; }

.nav-right { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.btn-logout {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
}
.btn-logout:hover { background: rgba(255, 255, 255, 0.24); }

/* Container */
.container {
  max-width: 1460px;
  margin: 0 auto;
  padding: 20px 24px 60px;
}

/* Cards & Buttons */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.card-title { margin: 0; font-size: 17px; font-weight: 700; color: var(--navy); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover:not(:disabled) { background: #132847; }
.btn-success { background: #15803d; color: #fff; }
.btn-success:hover:not(:disabled) { background: #166534; }
.btn-amber { background: #d97706; color: #fff; }
.btn-amber:hover:not(:disabled) { background: #b45309; }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover:not(:disabled) { background: var(--surface-alt); border-color: #94a3b8; }
.btn-danger-outline { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger-outline:hover:not(:disabled) { background: var(--danger-bg); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* Form fields */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 5px; }
.input, select.input, textarea.input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
textarea.input { resize: vertical; min-height: 64px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-exact { background: var(--exact-bg); color: var(--exact-fg); }
.badge-similar { background: var(--sim-bg); color: var(--sim-fg); }
.badge-manual { background: #e0e7ff; color: #3730a3; }
.badge-pending { background: #f1f5f9; color: #475569; }
.badge-unmatched { background: var(--danger-bg); color: var(--danger); }

/* Progress bar */
.job-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 9px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.job-banner.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.job-banner.done { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.progress-track {
  height: 8px;
  background: #dbeafe;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

/* Project grid */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 16px;
}
.project-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s, border-color 0.15s;
}
.project-card:hover { border-color: #93c5fd; transform: translateY(-2px); }
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 10px;
  margin: 12px 0;
  text-align: center;
}
.kpi-val { font-size: 15px; font-weight: 700; color: var(--navy); }
.kpi-lbl { font-size: 11.5px; color: var(--text-muted); }

/* Workbench */
.wb-toolbar {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: var(--shadow);
}
.wb-item-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.wb-item-head {
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.wb-item-body {
  display: grid;
  grid-template-columns: 310px 1fr 290px;
  gap: 18px;
  padding: 16px;
}
@media (max-width: 1120px) {
  .wb-item-body { grid-template-columns: 1fr; }
}
.img-box {
  width: 100%;
  height: 200px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: zoom-in;
  position: relative;
}
.img-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.img-box .empty-img { color: #94a3b8; font-size: 13px; }
.loc-box {
  background: #f0f7ff;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 12.5px;
  color: #1e3a8a;
  white-space: pre-line;
  margin: 8px 0;
  font-family: Consolas, "Microsoft YaHei", monospace;
}
.price-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.price-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 9px;
}
.price-box label { display: block; font-size: 11.5px; color: var(--text-muted); margin-bottom: 3px; }
.price-box input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}

/* Candidates strip */
.cand-strip {
  border-top: 1px dashed var(--border);
  background: #fafbfd;
  padding: 10px 16px;
}
.cand-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-top: 8px;
}
.cand-chip {
  flex: 0 0 155px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 7px;
  cursor: pointer;
  transition: all 0.15s;
}
.cand-chip:hover { border-color: var(--primary); }
.cand-chip.selected { border-color: #15803d; background: #f0fdf4; }
.cand-chip img {
  width: 100%;
  height: 92px;
  object-fit: contain;
  background: #f8fafc;
  border-radius: 5px;
}
.cand-meta { font-size: 11.5px; margin-top: 5px; line-height: 1.35; }

/* Sticky Summary Bar */
.summary-bar {
  position: sticky;
  bottom: 0;
  background: var(--navy);
  color: #fff;
  padding: 12px 22px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  z-index: 30;
}
.summary-stats { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; }
.summary-stat span { display: block; font-size: 11.5px; opacity: 0.78; }
.summary-stat strong { font-size: 18px; }

/* SKU catalog grid */
.sheet-pills { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.pill {
  padding: 5px 13px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: #fff;
  cursor: pointer;
  font-size: 12.5px;
  color: #334155;
  transition: all 0.15s;
  font-family: inherit;
}
.pill:hover { border-color: #93c5fd; background: #f8fafc; color: var(--navy); }
.pill.active { background: var(--navy); color: #fff; border-color: var(--navy); font-weight: 600; box-shadow: 0 2px 6px rgba(27, 54, 93, 0.2); }

.sku-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(242px, 1fr));
  gap: 16px;
}
.sku-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.sku-card:hover {
  transform: translateY(-2px);
  border-color: #93c5fd;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}
.sku-img-wrap {
  width: 100%;
  height: 174px;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  position: relative;
}
.sku-card img {
  width: 100%;
  height: 155px;
  object-fit: contain;
  background: #f8fafc;
  border-radius: 6px;
  cursor: zoom-in;
}
.sku-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
  border-radius: 4px;
  transition: transform 0.25s ease;
}
.sku-card:hover .sku-img-wrap img {
  transform: scale(1.035);
}
.sku-img-empty {
  color: #94a3b8;
  font-size: 12.5px;
}
.sku-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-top: 2px;
}
.sku-code-wrap {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
}
.sku-code {
  color: var(--navy);
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: 0.1px;
}
.sku-item-name {
  font-size: 12px;
  color: #475569;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.sku-price {
  color: #15803d;
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}
.sku-price .yen {
  font-size: 12.5px;
  font-weight: 700;
  margin-right: 1px;
}
.sku-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
}

/* Middle section: structured spec & tier pricing */
.sku-tiers {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sku-tier-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px dashed #eef2f6;
  font-size: 12px;
  line-height: 1.42;
}
.sku-tier-row:last-child { border-bottom: none; }
.sku-tier-spec {
  color: #1e293b;
  word-break: break-word;
  flex: 1;
}
.sku-tier-right {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.sku-tier-price {
  font-weight: 700;
  color: #0f172a;
}
.sku-tier-cell {
  font-size: 10.5px;
  color: #64748b;
  background: #f1f5f9;
  padding: 0 5px;
  border-radius: 4px;
  font-family: Consolas, "Microsoft YaHei", monospace;
}
.sku-tier-more {
  margin-top: 2px;
  padding: 2px 0;
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.sku-tier-more:hover { text-decoration: underline; }
.sku-remark {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11.5px;
  line-height: 1.45;
}

/* Bottom section: subtle refined Excel coordinate footer */
.sku-loc {
  margin-top: auto;
  background: #f5f8fc;
  border: 1px solid #dde7f5;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 11px;
  line-height: 1.5;
  color: #36537c;
  white-space: pre-line;
  font-family: Consolas, "Microsoft YaHei", monospace;
}

/* Pagination */
.cat-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}
.pg-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: #334155;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.pg-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pg-btn.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.pg-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.pg-ellipsis { padding: 0 3px; color: #94a3b8; font-weight: 700; }
.pg-jump {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.pg-jump input {
  width: 52px;
  height: 30px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  text-align: center;
  font-size: 12.5px;
  font-family: inherit;
}

/* Modal & Lightbox */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}
.modal-box.wide { max-width: 1050px; }
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  cursor: zoom-out;
  padding: 24px;
}
.lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }

/* Toast */
.toast {
  position: fixed;
  top: 72px;
  right: 24px;
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  z-index: 300;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #15803d; }

.muted { color: var(--text-muted); font-size: 12.5px; }
.hidden { display: none !important; }

/* Mobile & tablet responsiveness (LAN phone access) */
@media (max-width: 768px) {
  .navbar { height: auto; padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .nav-brand { font-size: 14.5px; }
  .nav-tabs { width: 100%; overflow-x: auto; padding-bottom: 2px; }
  .nav-tab { padding: 6px 10px; font-size: 13px; white-space: nowrap; }
  .container { padding: 12px 10px 80px; }
  .card { padding: 14px; }
  .wb-toolbar { padding: 12px; }
  .wb-item-body { padding: 12px; gap: 12px; }
  .wb-item-body > div:last-child { border-left: none !important; padding-left: 0 !important; border-top: 1px solid var(--border); padding-top: 12px; }
  .wb-item-body [style*="grid-template-columns:190px 1fr"] { grid-template-columns: 1fr !important; }
  .summary-bar { padding: 10px 14px; }
  .summary-stats { gap: 12px; }
  .summary-stat strong { font-size: 15px; }
  .sku-grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; }
  .sku-card { padding: 10px; }
  .sku-img-wrap { height: 145px; }
  .sku-code { font-size: 14px; }
  .sku-price { font-size: 15.5px; }
}
