:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --green: #16a34a;
  --amber: #d97706;
  --orange: #ea580c;
  --red: #dc2626;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* Topbar */
.topbar {
  background: linear-gradient(120deg, #1e3a8a, #2563eb);
  color: #fff;
  padding: 22px 0;
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 34px; line-height: 1; }
.topbar h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: .2px; }
.tagline { margin: 2px 0 0; font-size: 13.5px; color: #dbeafe; }
.topbar-actions { display: flex; gap: 10px; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 22px;
  padding-top: 26px;
  padding-bottom: 26px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

/* Fields */
.field { display: flex; flex-direction: column; gap: 6px; }
.field.grow { flex: 1; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.account-row { display: flex; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
input[type="text"] {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14.5px;
  color: var(--ink);
  background: #fff;
  width: 100%;
}
input[type="text"]:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

/* Dimension groups */
.dim {
  border-top: 1px solid var(--line);
  padding: 15px 0;
}
.dim:first-child { border-top: none; padding-top: 4px; }
.dim-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.dim-title { font-size: 15px; font-weight: 700; }
.dim-weight { font-size: 12px; color: var(--muted); background: #eef2ff; color: #4338ca; padding: 1px 8px; border-radius: 999px; }
.dim-hint { font-size: 12.5px; color: var(--muted); margin: 0 0 9px; }
.opt-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.opt {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13.5px;
  cursor: pointer;
  background: #fff;
  display: flex; align-items: center; gap: 8px;
  transition: border-color .12s, background .12s;
}
.opt:hover { border-color: #c7d2fe; }
.opt input { accent-color: var(--brand); margin: 0; }
.opt.selected { border-color: var(--brand); background: #eff4ff; font-weight: 600; }

/* Renewal chips */
.renewal-block { margin-top: 16px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  background: #fff;
  transition: all .12s;
}
.chip:hover { border-color: #c7d2fe; }
.chip.selected { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Save row */
.save-row { margin-top: 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--muted); }

/* Buttons */
.primary-btn {
  background: var(--brand); color: #fff; border: none;
  padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.primary-btn:hover { background: var(--brand-dark); }
.ghost-btn {
  background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.35);
  padding: 8px 14px; border-radius: 9px; font-size: 13px; cursor: pointer;
}
.ghost-btn:hover { background: rgba(255,255,255,.24); }
.result .ghost-btn, .result-actions .ghost-btn {
  background: #f1f5f9; color: var(--ink); border: 1px solid var(--line);
}
.result-actions .ghost-btn:hover { background: #e2e8f0; }

/* Score card */
.score-card { display: flex; gap: 18px; align-items: center; padding-bottom: 6px; }
.gauge { position: relative; width: 120px; height: 120px; flex: none; }
.gauge svg { transform: rotate(-90deg); }
.gauge-track { fill: none; stroke: #eef2f7; stroke-width: 12; }
.gauge-arc {
  fill: none; stroke: var(--brand); stroke-width: 12; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset .5s ease, stroke .3s ease;
}
.gauge-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-num { font-size: 34px; font-weight: 800; line-height: 1; }
.score-max { font-size: 12px; color: var(--muted); }
.score-meta { flex: 1; }
.tier-badge {
  display: inline-block; font-size: 13px; font-weight: 700; color: #fff;
  padding: 3px 12px; border-radius: 999px; background: var(--muted);
}
.headline { margin: 9px 0 4px; font-size: 14.5px; font-weight: 600; }
.tier-blurb { margin: 0; font-size: 13px; color: var(--muted); }

/* Blocks */
.block { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.block h2 { font-size: 15px; margin: 0 0 10px; }
.empty { color: var(--muted); font-size: 13.5px; margin: 4px 0; }

/* Flags */
.flags { display: flex; flex-direction: column; gap: 8px; }
.flag {
  border-radius: 10px; padding: 10px 12px; font-size: 13.5px;
  border-left: 4px solid var(--muted); background: #f8fafc;
}
.flag .flag-title { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.flag .flag-detail { color: var(--muted); margin-top: 2px; font-size: 12.8px; }
.flag.high { border-color: var(--red); background: #fef2f2; }
.flag.medium { border-color: var(--orange); background: #fff7ed; }
.flag.opportunity { border-color: var(--green); background: #f0fdf4; }

/* Actions */
.actions { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 7px; }
.actions li { font-size: 13.8px; }
.actions li.empty { list-style: none; margin-left: -20px; }

/* Breakdown */
.breakdown { display: flex; flex-direction: column; gap: 9px; }
.bd-row { display: grid; grid-template-columns: 120px 1fr 34px; align-items: center; gap: 10px; }
.bd-label { font-size: 13px; color: var(--ink); }
.bd-bar { height: 8px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.bd-fill { height: 100%; border-radius: 999px; transition: width .4s ease, background .3s; }
.bd-score { font-size: 12.5px; color: var(--muted); text-align: right; }

/* Portfolio */
.portfolio-wrap { padding-bottom: 40px; }
.portfolio-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.portfolio-head h2 { font-size: 18px; margin: 0; }
.count { font-size: 13px; color: #fff; background: var(--brand); border-radius: 999px; padding: 1px 9px; }
.portfolio { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.pcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  box-shadow: var(--shadow); cursor: pointer; position: relative; border-left-width: 5px;
}
.pcard:hover { border-color: #c7d2fe; }
.pcard-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pcard-name { font-weight: 700; font-size: 14.5px; }
.pcard-score { font-size: 22px; font-weight: 800; line-height: 1; }
.pcard-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.pcard-tier { font-size: 11.5px; font-weight: 700; }
.pcard-flags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.mini-flag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: #f1f5f9; color: var(--muted); }
.pcard-del {
  position: absolute; top: 8px; right: 8px; border: none; background: transparent;
  color: #cbd5e1; font-size: 16px; cursor: pointer; line-height: 1; padding: 2px 5px;
}
.pcard-del:hover { color: var(--red); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: #fff; padding: 20px 0 36px; }
.site-footer p { margin: 4px 0; font-size: 12.5px; color: var(--muted); }
.site-footer .fine { font-size: 11.5px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .opt-row { grid-template-columns: 1fr; }
  .topbar .wrap { align-items: flex-start; }
  .bd-row { grid-template-columns: 96px 1fr 30px; }
}
