:root {
  color-scheme: light;
  --ink: #152536;
  --muted: #627184;
  --line: #dce4ec;
  --soft: #f4f7fa;
  --panel: #ffffff;
  --navy: #173b57;
  --blue: #236b8e;
  --blue-soft: #eaf4f8;
  --amber: #9a5a00;
  --amber-soft: #fff3d6;
  --red: #9f2d2d;
  --red-soft: #fdeaea;
  --green: #28755b;
  --green-soft: #e7f4ee;
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #eef3f6;
  color: var(--ink);
  font-size: 14px;
}

button, input, select { font: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px max(28px, calc((100vw - 1480px) / 2));
  color: #fff;
  background: linear-gradient(118deg, #12364f 0%, #1d5a74 62%, #2b7886 100%);
  box-shadow: 0 8px 28px rgb(15 43 61 / 18%);
}

.eyebrow {
  margin: 0 0 6px;
  color: #bfe1e8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1 { margin: 0; font-size: 30px; letter-spacing: -.02em; }
.subtitle { margin: 7px 0 0; color: #dcebf0; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.logout-form { margin: 0; }

main {
  width: min(1480px, calc(100% - 40px));
  margin: 28px auto 56px;
}

.panel, .results {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 6px 20px rgb(26 54 73 / 7%);
}

.upload-panel { padding: 24px; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-heading > div { display: flex; align-items: center; gap: 10px; }
.section-heading h2 { margin: 0; font-size: 18px; }
.section-heading p { margin: 0; color: var(--muted); }
.step {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 128px;
  border: 1.5px dashed #8aa9bb;
  border-radius: 12px;
  background: #f7fbfc;
  cursor: pointer;
  text-align: center;
  transition: .18s ease;
}

.dropzone:hover { border-color: var(--blue); background: var(--blue-soft); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone strong { color: var(--blue); font-size: 16px; }
.dropzone span { margin-top: -24px; color: var(--muted); font-size: 13px; }

.file-settings {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.file-settings.empty { padding: 18px; color: var(--muted); text-align: center; }

.file-row {
  display: grid;
  grid-template-columns: minmax(230px, 1.6fr) minmax(180px, 1fr);
  gap: 18px;
  align-items: end;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
}

.file-row:last-child { border-bottom: 0; }
.file-row > div { align-self: center; min-width: 0; }
.file-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
label > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }

input, select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #c9d4de;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input:focus, select:focus { outline: 3px solid rgb(35 107 142 / 13%); border-color: var(--blue); }

.rule-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr)) minmax(250px, 1.3fr);
  gap: 14px;
  align-items: end;
  margin-top: 16px;
  padding: 15px;
  border-radius: 10px;
  background: var(--soft);
}

.suffix-input { display: grid; grid-template-columns: 1fr 42px; }
.suffix-input input { border-radius: 8px 0 0 8px; }
.suffix-input span {
  display: grid;
  place-items: center;
  border: 1px solid #c9d4de;
  border-left: 0;
  border-radius: 0 8px 8px 0;
  color: var(--muted);
  background: #fff;
}

.rule-note { margin: 0 0 7px; color: var(--muted); line-height: 1.55; }

.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.button {
  min-height: 40px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}
.button:disabled { cursor: not-allowed; opacity: .5; }
.button-primary { background: #fff; color: var(--navy); border-color: #fff; }
.upload-panel .button-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.button-secondary { background: #fff; color: var(--ink); border-color: #b9c7d2; }
.status-text { color: var(--muted); }
.status-text.error { color: var(--red); }

.results { margin-top: 22px; padding: 22px; }
.hidden { display: none !important; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
}

.summary-card {
  min-height: 90px;
  padding: 15px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--blue);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.summary-card:hover { border-color: #8fb4c6; box-shadow: 0 5px 14px rgb(26 54 73 / 10%); transform: translateY(-1px); }
.summary-card.active { border-color: var(--blue); background: var(--blue-soft); box-shadow: 0 0 0 2px rgb(35 107 142 / 12%); }
.summary-grid span { display: block; color: var(--muted); font-size: 12px; }
.summary-grid strong { display: block; margin-top: 7px; font-size: 27px; }
.summary-grid small { display: block; margin-top: 5px; color: var(--blue); font-size: 11px; }
.summary-grid .warning-card { border-top-color: #d18a22; }

.summary-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 700;
}
.summary-filter button {
  padding: 4px 9px;
  border: 1px solid #9dc2d1;
  border-radius: 6px;
  background: #fff;
  color: var(--blue);
  cursor: pointer;
}

.notice {
  margin-top: 16px;
  padding: 12px 14px;
  border-left: 4px solid #d18a22;
  background: var(--amber-soft);
  color: #6f4a12;
  line-height: 1.55;
}

.tabs { display: flex; gap: 4px; margin-top: 22px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 11px 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}
.tab.active { border-bottom-color: var(--blue); color: var(--blue); }
.tab-panel { display: none; padding-top: 15px; }
.tab-panel.active { display: block; }

.toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) 220px; gap: 10px; margin-bottom: 12px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 11px;
  border-right: 1px solid rgb(255 255 255 / 20%);
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  text-align: center;
}
td { padding: 9px 11px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #f5f9fb; }
.name-cell { max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.market-input { min-width: 110px; min-height: 32px; padding: 5px 7px; }
.offer-list { display: grid; min-width: 285px; gap: 6px; white-space: normal; }
.offer-line {
  display: grid;
  grid-template-columns: minmax(105px, 1fr) auto auto;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
}
.offer-line.best-offer { border-color: #8fc7a5; background: var(--green-soft); }
.offer-supplier { min-width: 0; font-weight: 700; }
.offer-supplier small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; font-weight: 400; }
.offer-price { color: var(--ink); font-variant-numeric: tabular-nums; }
.offer-best-label { padding: 3px 6px; border-radius: 999px; background: var(--green); color: #fff; font-size: 11px; font-weight: 700; }
.tag { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.tag-good { background: var(--green-soft); color: var(--green); }
.tag-warn { background: var(--amber-soft); color: var(--amber); }
.tag-bad { background: var(--red-soft); color: var(--red); }
.tag-neutral { background: #edf1f4; color: #536273; }

.reviews-list { display: grid; gap: 12px; }
.review-card { padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.review-card header { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.review-card h3 { margin: 0; font-size: 15px; }
.review-card p { margin: 8px 0 0; color: var(--muted); }
.review-products { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 13px; }
.review-products div { padding: 12px; border-radius: 8px; background: var(--soft); }
.review-products strong { display: block; margin-bottom: 5px; }
.empty-state { padding: 34px; color: var(--muted); text-align: center; border: 1px dashed #b9c7d2; border-radius: 10px; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(135deg, #12364f 0%, #1d5a74 58%, #eaf4f8 58%, #eef3f6 100%);
}
.login-shell { width: min(430px, 100%); margin: 0; }
.login-card { padding: 30px; }
.login-card .eyebrow { color: var(--blue); }
.login-card h1 { margin-bottom: 10px; }
.login-card > p:not(.eyebrow) { color: var(--muted); }
.login-card form { display: grid; gap: 16px; margin-top: 24px; }
.login-card .button-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.login-error { padding: 10px 12px; border-radius: 8px; background: var(--red-soft); color: var(--red) !important; }

@media (max-width: 1100px) {
  .rule-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 720px) {
  .topbar { align-items: flex-start; padding: 22px 18px; }
  .topbar .button { flex: 0 0 auto; }
  .top-actions { flex-direction: column; align-items: stretch; }
  main { width: calc(100% - 20px); margin-top: 12px; }
  .section-heading { display: block; }
  .section-heading p { margin-top: 9px; }
  .file-row, .rule-grid, .summary-grid, .toolbar, .review-products { grid-template-columns: 1fr; }
  .form-actions { flex-wrap: wrap; }
}
