:root {
  color-scheme: light;
  --ink: #182521;
  --muted: #596761;
  --line: #d7dfdb;
  --surface: #ffffff;
  --canvas: #f4f6f5;
  --green: #155c4d;
  --green-hover: #0e493d;
  --coral: #b54735;
  --gold: #896418;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-size: 16px;
  line-height: 1.6;
}

a { color: var(--green); text-underline-offset: 3px; }
a:hover { color: var(--green-hover); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  min-height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand, .topbar nav, .toolbar, .button, .icon-button, .candidate-header, .candidate-metrics {
  display: flex;
  align-items: center;
}

.brand { gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: #fff; background: var(--green); border-radius: 6px; font-size: 14px; }
.topbar nav { gap: 24px; }
.topbar nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.topbar nav a:hover { color: var(--green); }

.page-shell { width: min(1120px, calc(100% - 48px)); margin: 0 auto; }
.intro { display: grid; grid-template-columns: 128px minmax(0, 1fr); align-items: center; gap: 24px; padding: 34px 0 28px; border-bottom: 1px solid var(--line); }
.intro img { display: block; width: 128px; height: 84px; border-radius: 6px; object-fit: cover; }
.eyebrow, .section-index, .candidate-index { margin: 0 0 6px; color: var(--green); font-size: 12px; font-weight: 700; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: 30px; line-height: 1.25; font-weight: 720; }
.intro-copy { max-width: 740px; margin: 8px 0 0; color: var(--muted); }

.workspace { padding: 28px 0 32px; border-bottom: 1px solid var(--line); }
.workspace-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.workspace-heading h2, .section-heading h2, .method h2 { margin: 0; font-size: 21px; line-height: 1.35; }
.toolbar { justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.currency-control { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
select, input, textarea { width: 100%; min-height: 40px; padding: 8px 10px; color: var(--ink); background: #fff; border: 1px solid #aebbb5; border-radius: 5px; }
select:focus, input:focus, textarea:focus, button:focus-visible, a:focus-visible, .table-scroll:focus-visible { outline: 3px solid #e0ad4f; outline-offset: 2px; }
.currency-control select { width: 148px; min-height: 38px; }
.button, .icon-button { min-height: 38px; justify-content: center; gap: 7px; border: 1px solid #aebbb5; border-radius: 5px; background: #fff; color: var(--ink); }
.button { padding: 7px 12px; font-size: 13px; font-weight: 650; }
.button-primary { color: #fff; background: var(--green); border-color: var(--green); }
.button-primary:hover { background: var(--green-hover); }
.button-quiet:hover, .icon-button:hover { background: #edf3f0; border-color: var(--green); }
.icon-button { width: 40px; padding: 0; }
.button svg, .icon-button svg { width: 16px; height: 16px; }
.unit-note { margin: 16px 0 20px; padding-left: 12px; border-left: 3px solid #d3a846; color: var(--muted); font-size: 13px; }

.weight-controls { display: grid; grid-template-columns: minmax(260px, 1.5fr) repeat(3, minmax(125px, .7fr)); gap: 14px; align-items: end; margin: 20px 0; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.weight-controls h3 { margin: 0 0 3px; font-size: 15px; }
.weight-controls p { margin: 0; color: var(--muted); font-size: 12px; }
.weight-controls label, .form-grid label, .ratings label { display: grid; gap: 5px; color: #31413a; font-size: 12px; font-weight: 650; }
.weight-controls input { min-height: 36px; }

.candidate-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.candidate { min-width: 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.candidate-header { justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.candidate-index { margin-bottom: 2px; }
.candidate-title { margin: 0; font-size: 17px; line-height: 1.35; }
.candidate-header .icon-button { width: 34px; min-height: 34px; color: var(--coral); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding-top: 14px; }
.form-grid input, .form-grid select, .form-grid textarea { font-size: 14px; }
.form-grid textarea { min-height: 60px; resize: vertical; }
.money-label { color: var(--muted); font-weight: 500; }
.ratings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0 0; padding: 12px 0 0; border: 0; border-top: 1px solid var(--line); }
.ratings legend { float: left; width: 100%; margin-bottom: 8px; padding: 0; color: var(--muted); font-size: 12px; font-weight: 650; }
.ratings label input { font-size: 14px; }
.candidate-metrics { flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--green-hover); font-size: 12px; font-weight: 700; }
.candidate-metrics span { min-width: 0; }

.results { padding: 28px 0 30px; border-bottom: 1px solid var(--line); }
.section-heading { margin-bottom: 14px; }
.section-heading .section-index { margin-bottom: 4px; }
.table-scroll { max-width: 100%; overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; min-width: 900px; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid #e5eae7; }
th { color: #34443d; background: #edf3f0; font-size: 12px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td:first-child { max-width: 180px; font-weight: 700; overflow-wrap: anywhere; }
.results-note { margin: 10px 0 0; color: var(--muted); font-size: 12px; }

.method { display: grid; grid-template-columns: minmax(210px, .7fr) minmax(0, 1.8fr); gap: 36px; padding: 28px 0 34px; }
.method-copy p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.method-copy p:last-child { margin-bottom: 0; }
.site-footer { display: flex; justify-content: center; flex-wrap: wrap; gap: 22px; padding: 18px 24px; background: #fff; border-top: 1px solid var(--line); font-size: 13px; }
.site-footer a { text-decoration: none; }
.site-footer span { color: var(--muted); }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 20px; max-width: calc(100vw - 32px); padding: 10px 14px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; color: #fff; background: #203c33; border-radius: 5px; font-size: 13px; transition: opacity .18s ease, transform .18s ease; }
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 900px) {
  .workspace-heading { align-items: flex-start; flex-direction: column; }
  .toolbar { justify-content: flex-start; }
  .weight-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .weight-controls > div { grid-column: 1 / -1; }
  .method { grid-template-columns: minmax(0, 1fr); gap: 14px; }
}

@media (max-width: 680px) {
  .topbar { min-height: 58px; padding: 0 16px; }
  .topbar nav { gap: 12px; }
  .topbar nav a { font-size: 12px; }
  .brand { gap: 7px; font-size: 13px; }
  .brand-mark { width: 30px; height: 30px; }
  .page-shell { width: min(100% - 32px, 540px); }
  .intro { grid-template-columns: 84px minmax(0, 1fr); gap: 14px; padding: 24px 0 20px; }
  .intro img { width: 84px; height: 66px; }
  h1 { font-size: 24px; }
  .intro-copy { font-size: 14px; }
  .workspace, .results, .method { padding-top: 22px; padding-bottom: 24px; }
  .workspace-heading h2, .section-heading h2, .method h2 { font-size: 19px; }
  .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .currency-control { grid-column: 1 / -1; justify-content: space-between; }
  .currency-control select { width: min(220px, 65%); }
  .button { min-width: 0; }
  .icon-button { min-width: 40px; }
  .weight-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .weight-controls label { font-size: 11px; }
  .candidate-list { grid-template-columns: minmax(0, 1fr); }
  .candidate { padding: 13px; }
  .form-grid { gap: 10px; }
  .form-grid label { font-size: 11px; }
  .form-grid input, .form-grid select, .form-grid textarea { padding: 8px; }
  .ratings { gap: 7px; }
  .ratings label { font-size: 10px; }
  .site-footer { gap: 12px 18px; }
}

@media (max-width: 390px) {
  .topbar nav a { font-size: 11px; }
  .intro { grid-template-columns: 64px minmax(0, 1fr); gap: 10px; }
  .intro img { width: 64px; height: 60px; }
  h1 { font-size: 22px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .weight-controls { grid-template-columns: minmax(0, 1fr); }
  .weight-controls > div { grid-column: auto; }
  .ratings { grid-template-columns: minmax(0, 1fr); }
  .ratings legend { margin-bottom: 6px; }
}

@media print {
  body { background: #fff; }
  .topbar, .toolbar, .remove-candidate, .site-footer, .toast { display: none !important; }
  .page-shell { width: 100%; }
  .candidate, .table-scroll { break-inside: avoid; }
  .table-scroll { overflow: visible; }
  table { min-width: 0; font-size: 9px; }
  th, td { padding: 5px; }
  a { color: inherit; }
}
