:root {
  --ink: #162620;
  --muted: #63716b;
  --green: #176b50;
  --green-dark: #0f513d;
  --cream: #f4f0e6;
  --card: #fffdf8;
  --line: #ded9cc;
  --gold: #d4a843;
  --red: #a63d40;
  --focus: #4aaa8070;
  --shadow-hover: 0 12px 30px #173d2c16;
  font-size: 17px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  background: var(--cream);
  color: var(--ink);
  font-family: "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

header {
  min-height: 72px;
  padding: 0 max(24px, calc((100vw - 1240px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--green-dark);
  color: white;
}

.brand { font-size: 19px; font-weight: 750; letter-spacing: .03em; }
nav { display: flex; align-items: center; gap: 20px; font-size: 15px; }
nav a { padding: 8px 10px; color: #d9eee5; text-decoration: none; border-radius: 8px; transition: color .18s ease, background .18s ease; }
nav span { padding-left: 20px; border-left: 1px solid #ffffff40; }

main { max-width: 1240px; margin: auto; padding: 32px 24px 64px; }
footer { text-align: center; color: var(--muted); padding: 24px; font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 28px #2b46360c;
}

.login { max-width: 480px; margin: 9vh auto; padding: 40px; }
.login h1, .narrow h1 { font-size: 32px; margin: 8px 0; }
.login p, .hero p, .product-head p, .publish-card p { color: var(--muted); }

form { display: grid; gap: 18px; }
label { display: grid; gap: 8px; font-size: 16px; font-weight: 650; }
input {
  width: 100%;
  border: 1px solid #c9c3b7;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 17px;
  background: white;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input:focus { outline: 0; border-color: var(--green); box-shadow: 0 0 0 3px var(--focus); }
input:disabled { color: #68736e; background: #f0eee8; cursor: not-allowed; }

button, .button-link {
  border: 0;
  border-radius: 10px;
  background: var(--green);
  color: white;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  box-shadow: 0 3px 8px #124d3917;
  transition: transform .16s ease, background .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease;
}
button:active, .button-link:active { transform: translateY(1px); box-shadow: 0 1px 3px #124d3917; }
button:disabled { box-shadow: none; opacity: .58; }
.secondary { background: #e8ece8; color: var(--green-dark); box-shadow: none; }
.error { background: #fde9e7; color: var(--red); padding: 12px; border-radius: 10px; }
.notice { background: #e8f2ed; color: var(--green-dark); border: 1px solid #b8d5c7; padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; }
.eyebrow { text-transform: uppercase; color: var(--green); font-size: 13px; font-weight: 800; letter-spacing: .14em; }

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 32px 36px;
  margin-bottom: 24px;
  background: linear-gradient(125deg, #fffdf8, #e4eee7);
  border: 1px solid var(--line);
  border-radius: 20px;
}
.hero h1 { font-family: inherit; font-size: 38px; font-weight: 720; letter-spacing: -.02em; margin: 7px 0; }
.hero p { margin: 0; max-width: 700px; font-size: 16px; line-height: 1.7; }
.hero.compact { padding: 25px 32px; }
.hero.compact h1 { font-size: 32px; }
.hero-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.progress-ring { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--green) var(--p), #d8ddd8 0); position: relative; }
.progress-ring::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #f9faf6; }
.progress-ring b { z-index: 1; font-size: 20px; }

.type-picker { display: flex; gap: 9px; overflow: auto; padding: 5px 0 18px; }
.chip { white-space: nowrap; padding: 10px 14px; border: 1px solid transparent; border-radius: 30px; background: #e6e1d7; color: var(--ink); text-decoration: none; font-size: 15px; transition: transform .16s ease, background .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease; }
.chip b { margin-left: 4px; color: var(--muted); }
.chip.active { background: var(--green); color: white; }
.chip.active b { color: #d6e9e1; }

.section-title { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 10px; }
.section-title h2 { margin: 0; font-family: inherit; font-weight: 700; letter-spacing: -.01em; }
.section-title span { font-size: 14px; color: var(--muted); }
.table-card, .result-group { overflow: hidden; }
.table-card { position: relative; transition: opacity .18s ease, transform .18s ease; }
.table-card.is-loading { opacity: .55; transform: translateY(2px); pointer-events: none; }
.table-card.is-loading::after {
  content: "";
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  width: 34%;
  height: 3px;
  border-radius: 3px;
  background: var(--green);
  animation: table-loading .8s ease-in-out infinite alternate;
}
@keyframes table-loading { to { left: 66%; } }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; background: #eeeae0; color: #59655f; padding: 13px 14px; font-size: 14px; white-space: nowrap; }
td { padding: 15px 14px; border-top: 1px solid #e6e1d8; vertical-align: middle; }
td small { display: block; color: var(--muted); margin-top: 5px; max-width: 380px; line-height: 1.5; }

.status { padding: 5px 9px; border-radius: 20px; font-size: 13px; }
.status.done { background: #dceee5; color: var(--green-dark); }
.status.draft { background: #eee8da; color: #785e24; }
.action, .back { font-weight: 700; color: var(--green); text-decoration: none; transition: color .16s ease, background .16s ease, border-color .16s ease, transform .16s ease; }
.action { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 6px 10px; border-radius: 8px; }
.back {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-bottom: 18px;
  padding: 8px 12px;
  border: 1px solid #b9cec4;
  border-radius: 9px;
  background: #f4faf6;
  font-size: 14px;
}
.result-banner { display: block; margin: -8px 0 20px; background: var(--gold); color: #2d260f; padding: 14px 18px; border-radius: 12px; text-decoration: none; font-weight: 700; transition: transform .16s ease, filter .16s ease, box-shadow .16s ease; }

.product-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 26px 30px;
  background: linear-gradient(120deg, #fffdf8, #edf3ee);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.product-head h1 { font-family: inherit; font-size: 34px; font-weight: 720; letter-spacing: -.02em; margin: 5px 0; }
.product-head p { font-size: 16px; }
.total-badge { background: var(--green-dark); color: white; padding: 13px 18px; border-radius: 14px; }
.total-badge strong { font-size: 28px; margin-left: 8px; }

.criteria-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.criterion {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid #8bb5a2;
  border-radius: 15px;
  padding: 22px 24px;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 132px;
  gap: 24px;
  align-items: center;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.criterion:focus-within { border-left-color: var(--green); box-shadow: 0 0 0 3px #4aaa8026, var(--shadow-hover); }
.criterion-head span { font-size: 13px; color: var(--green); font-weight: 800; }
.criterion h3 { margin: 4px 0; font-size: 21px; font-weight: 680; letter-spacing: -.01em; }
.criterion p { grid-column: 2; margin: 0; padding-left: 24px; border-left: 1px solid #e2ddd3; color: #46534e; font-size: 17px; font-weight: 400; line-height: 1.8; letter-spacing: .01em; }
.score-input, .auto-score { grid-column: 3; grid-row: 1; align-self: center; justify-self: end; }
.score-input { display: flex; align-items: center; gap: 7px; }
.score-input input { width: 92px; font-size: 24px; font-weight: 750; text-align: center; padding: 12px; border-color: #aebdb5; }
.score-input span { color: var(--muted); white-space: nowrap; font-size: 17px; }
.auto-score { text-align: center; color: var(--green); }
.auto-score b { display: block; font-size: 34px; }
.auto-score span { font-size: 14px; }

.form-actions { display: flex; justify-content: flex-end; gap: 12px; position: sticky; bottom: 16px; z-index: 4; background: #fffdf8ed; border: 1px solid var(--line); box-shadow: 0 8px 30px #203d2f18; backdrop-filter: blur(10px); padding: 14px 16px; margin-top: 18px; border-radius: 14px; }
.locked { margin-top: 16px; padding: 18px; background: #e7e4dc; border-radius: 12px; text-align: center; color: var(--muted); }
.narrow { max-width: 520px; margin: 5vh auto; padding: 32px; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.metrics article { background: var(--card); padding: 20px; border: 1px solid var(--line); border-radius: 14px; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.metrics span { display: block; color: var(--muted); font-size: 14px; }
.metrics b { font-size: 28px; }
.expert-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.expert-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: grid; grid-template-columns: 1fr auto; align-items: center; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.expert-card span { color: var(--muted); font-size: 13px; }
.expert-card h3 { margin: 3px 0; }
.expert-card > strong { font-size: 25px; }
.expert-card small { font-size: 12px; color: var(--muted); }
.bar { grid-column: 1 / -1; height: 5px; background: #e2ded5; border-radius: 5px; margin-top: 14px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); }
.publish-card { margin-top: 26px; padding: 24px; display: flex; align-items: center; justify-content: space-between; }
.publish-card h2 { margin: 0; }
.publish-card p { margin-bottom: 0; }
.result-group { margin-bottom: 22px; border-radius: 20px; }
.result-group .section-title { min-height: 76px; padding: 18px 22px; background: linear-gradient(100deg, #fffdf8, #f7faf7); border-bottom: 1px solid #e8e4da; }
.result-group .section-title h2 { font-size: 23px; }
.result-group th { background: #f4f5f1; color: #6a746f; }
.result-group tbody tr, .table-card tbody tr { background: #fffdf8; transition: background .15s ease, box-shadow .15s ease; }
.rank { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #ebe7df; font-weight: 800; }
.winner { box-shadow: inset 3px 0 0 #a7c8b8; }
.winner .rank { background: var(--green); color: white; }
.result-group tbody .winner:nth-child(1) .rank { background: #c79a32; }
.result-group tbody .winner:nth-child(2) .rank { background: #84918b; }
.result-group tbody .winner:nth-child(3) .rank { background: #a86f49; }
.category-stepper { display: flex; grid-auto-flow: column; align-items: center; gap: 10px; }
.stepper-label { color: #53615b; font-size: 14px; font-weight: 650; }
.stepper-control { display: grid; grid-template-columns: 34px 42px 34px; align-items: center; height: 36px; overflow: hidden; border: 1px solid #c9d5cf; border-radius: 10px; background: white; }
.stepper-control button { display: grid; place-items: center; min-width: 0; height: 100%; padding: 0; border-radius: 0; background: transparent; color: var(--green-dark); font-size: 20px; font-weight: 500; }
.stepper-control button:disabled { color: #c5cbc8; cursor: not-allowed; }
.stepper-control strong { display: grid; place-items: center; height: 100%; border-right: 1px solid #e0e6e2; border-left: 1px solid #e0e6e2; color: var(--ink); font-size: 16px; }
.stepper-total { color: var(--muted); font-size: 13px; white-space: nowrap; }

:where(a, button, input):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
input:focus-visible { outline: 0; }

@media (hover: hover) and (pointer: fine) {
  nav a:hover { color: white; background: #ffffff17; }
  button:hover:not(:disabled), .button-link:hover { background: #0f5b43; transform: translateY(-1px); box-shadow: 0 7px 16px #124d3928; }
  .secondary:hover { background: #dce5df; color: #0b4936; box-shadow: 0 5px 12px #183e2d12; }
  .chip:hover { background: #d9e4dd; border-color: #b1c8bc; transform: translateY(-1px); box-shadow: 0 4px 10px #173d2c12; }
  .chip.active:hover { background: var(--green-dark); border-color: var(--green-dark); }
  .action:hover { color: var(--green-dark); background: #e7f1ec; }
  .back:hover { background: #e5f1eb; border-color: #8ab39f; transform: translateX(-2px); }
  .result-banner:hover { filter: brightness(1.04); transform: translateY(-1px); box-shadow: 0 8px 18px #876a2426; }
  .criterion:hover { border-color: #b8cfc3; border-left-color: var(--green); box-shadow: var(--shadow-hover); transform: translateY(-2px); }
  .metrics article:hover, .expert-card:hover { border-color: #b9cec4; box-shadow: var(--shadow-hover); transform: translateY(-2px); }
  .result-group tbody tr:hover, .table-card tbody tr:hover { background: #f4f8f5; box-shadow: inset 3px 0 0 #80ad97; }
  .stepper-control button:hover:not(:disabled) { background: #e8f1ec; }
}

@media (hover: none) {
  button:active:not(:disabled), .button-link:active, .chip:active, .action:active, .back:active { filter: brightness(.94); }
  .table-card tr:active, .result-group tr:active { background: #f0f6f2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 800px) {
  :root { font-size: 16px; }
  header { min-height: auto; padding: 14px 18px; display: block; }
  .brand { margin-bottom: 8px; font-size: 17px; }
  nav { width: 100%; gap: 6px 14px; overflow-x: auto; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav a, nav span { display: inline-flex; align-items: center; min-height: 40px; white-space: nowrap; }
  nav span { margin-left: auto; padding-left: 14px; }
  main { padding: 18px 14px calc(48px + env(safe-area-inset-bottom)); }
  footer { padding: 20px 14px calc(20px + env(safe-area-inset-bottom)); }
  .hero { padding: 22px; gap: 18px; }
  .hero h1 { font-size: 29px; }
  .hero.compact { padding: 22px; }
  .hero.compact h1 { font-size: 28px; }
  .hero-actions { justify-content: flex-end; }
  .progress-ring { width: 78px; height: 78px; flex: none; }
  .criteria-grid, .expert-grid { grid-template-columns: 1fr; }
  .criterion { grid-template-columns: 1fr; gap: 12px; padding: 20px; }
  .criterion p { grid-column: 1; padding: 14px 0 0; border-left: 0; border-top: 1px solid #e2ddd3; }
  .score-input, .auto-score { grid-column: 1; grid-row: auto; justify-self: start; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .publish-card, .product-head { align-items: flex-start; gap: 18px; flex-direction: column; }
  .product-head { padding: 22px; }
  .product-head h1 { font-size: 29px; overflow-wrap: anywhere; }
  .result-group .section-title { align-items: flex-start; gap: 12px; flex-direction: column; }
  .category-stepper { width: 100%; grid-auto-flow: column; justify-content: start; }
  .stepper-control { grid-template-columns: 42px 48px 42px; height: 42px; }
  .form-actions { bottom: max(10px, env(safe-area-inset-bottom)); }
  .login { margin: 3vh auto; padding: 26px; }
}

@media (max-width: 600px) {
  header { padding-right: 14px; padding-left: 14px; }
  nav { flex-wrap: wrap; overflow-x: visible; }
  nav span { order: -1; width: 100%; margin-left: 0; min-height: 30px; padding-left: 0; border-left: 0; color: #b9d8ca; }
  main { padding-right: 10px; padding-left: 10px; }
  .card, .hero, .product-head { border-radius: 14px; }
  .hero { align-items: flex-start; padding: 18px; }
  .hero:not(.admin-hero):not(.compact) { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .admin-hero, .hero.compact { flex-direction: column; }
  .admin-hero .button-link, .hero.compact .hero-actions { width: 100%; }
  .hero-actions .button-link { flex: 1 1 130px; }
  .hero p { font-size: 15px; line-height: 1.6; }
  .hero h1, .hero.compact h1 { font-size: 26px; }
  .progress-ring { width: 66px; height: 66px; }
  .progress-ring::after { inset: 7px; }
  .progress-ring b { font-size: 17px; }
  .section-title { padding: 17px 16px 9px; }
  .section-title h2 { font-size: 21px; overflow-wrap: anywhere; }
  .type-picker { margin-right: -10px; margin-left: -10px; padding: 4px 10px 15px; scroll-padding-left: 10px; }
  .chip { min-height: 42px; display: inline-flex; align-items: center; }
  button, .button-link, .action { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .metrics { gap: 9px; }
  .metrics article { padding: 16px; }
  .metrics b { font-size: 24px; }
  .expert-card { padding: 16px; }

  .table-card .table-scroll, .result-group .table-scroll { overflow: visible; }
  .table-card table, .table-card tbody, .table-card tr,
  .result-group table, .result-group tbody, .result-group tr { display: block; width: 100%; }
  .table-card thead, .result-group thead { display: none; }
  .table-card tbody, .result-group tbody { padding: 0 10px 10px; }
  .table-card tr, .result-group tr {
    margin-bottom: 10px;
    padding: 11px 13px;
    border: 1px solid #e2ddd3;
    border-radius: 12px;
    background: #fffdf8;
  }
  .table-card td, .result-group td {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    min-height: 36px;
    padding: 8px 0;
    border-top: 1px solid #eee9e0;
    overflow-wrap: anywhere;
  }
  .table-card td:first-child, .result-group td:first-child { border-top: 0; }
  .table-card td::before, .result-group td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
    line-height: 1.6;
  }
  .table-card td.row-action { display: block; padding: 8px 0 0 96px; }
  .table-card td.row-action::before { display: none; }
  .table-card .row-action .action { width: 100%; border: 1px solid #b9cec4; border-radius: 9px; background: #f4faf6; }
  .result-group .winner { box-shadow: inset 3px 0 0 #a7c8b8; }
  .rank { width: 28px; height: 28px; }
  td small { max-width: none; }

  .criterion { padding: 17px; }
  .criterion h3 { font-size: 19px; }
  .criterion p { font-size: 16px; line-height: 1.65; }
  .score-input { width: 100%; justify-content: flex-end; }
  .score-input input { width: 116px; min-height: 52px; }
  .auto-score { justify-self: end; text-align: right; }
  .form-actions { gap: 8px; padding: 10px; }
  .form-actions button { flex: 1; padding-right: 10px; padding-left: 10px; }
  .narrow, .login { margin: 16px auto; padding: 22px 18px; }
  .login h1, .narrow h1 { font-size: 28px; }
}

@media (max-width: 380px) {
  .hero:not(.admin-hero):not(.compact) { display: flex; flex-direction: column; }
  .progress-ring { align-self: flex-end; }
  .metrics { grid-template-columns: 1fr; }
  .category-stepper { flex-wrap: wrap; }
  .stepper-label { width: 100%; }
}
