:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #16202e;
  --ink-soft: #54607a;
  --muted: #8a95ad;
  --line: #e4e9f2;
  --brand: #2f54eb;
  --brand-ink: #1d39c4;
  --brand-wash: #eef2ff;
  --good: #14a06a;
  --warn: #d98300;
  --bad: #e0483b;
  --shadow: 0 1px 2px rgba(20, 32, 46, .05), 0 8px 24px rgba(20, 32, 46, .07);
  --radius: 14px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(1180px, 100% - 40px); margin-inline: auto; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), #5b78ff);
  color: #fff; font-size: 22px; line-height: 1;
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.brand-sub { color: var(--muted); font-size: 12.5px; }
.topbar-actions { display: flex; gap: 8px; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 20px;
  padding: 22px 0 60px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.report-panel { position: sticky; top: 76px; }
.panel-head h1 { font-size: 16px; margin: 0 0 4px; }
.panel-head .muted { margin: 0 0 14px; }
.muted { color: var(--muted); font-size: 13px; }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.report-actions { display: flex; gap: 8px; }

/* Buttons */
.btn {
  font: inherit; font-size: 13.5px; font-weight: 600;
  border-radius: 9px; padding: 8px 14px;
  border: 1px solid transparent; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-ghost { background: #fff; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { background: #f7f9fd; color: var(--ink); }
.btn-add {
  width: 100%; margin-top: 6px;
  background: var(--brand-wash); color: var(--brand-ink);
  border: 1px dashed #b9c6ff; padding: 11px;
}
.btn-add:hover { background: #e4ebff; }

/* Fields */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
input[type="text"], input[type="number"] {
  width: 100%; font: inherit; font-size: 14px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: #fcfdff; color: var(--ink);
}
input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47, 84, 235, .12); }

/* Step cards */
.step-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.step-card {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; background: #fbfcff;
}
.step-card-top { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.step-num {
  flex: none; width: 24px; height: 24px; border-radius: 7px;
  background: var(--brand-wash); color: var(--brand-ink);
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700;
}
.step-name-input { flex: 1; }
.step-del {
  flex: none; border: none; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 7px;
}
.step-del:hover { background: #fbe9e7; color: var(--bad); }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.metric .field-label { font-size: 11.5px; }
.metric input { padding: 7px 9px; font-size: 13.5px; }

.flags { display: flex; flex-wrap: wrap; gap: 7px; }
.flag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 11px; cursor: pointer; user-select: none; background: #fff;
  transition: background .12s, border-color .12s, color .12s;
}
.flag input { accent-color: var(--brand); margin: 0; }
.flag.on { background: var(--brand-wash); border-color: #b9c6ff; color: var(--brand-ink); }

/* How-to */
.howto { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.howto summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.howto ul { margin: 10px 0 0; padding-left: 18px; color: var(--ink-soft); font-size: 13px; }
.howto li { margin-bottom: 5px; }

/* Report */
.report { display: flex; flex-direction: column; gap: 16px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 14px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.kpi { background: #fbfcff; border: 1px solid var(--line); border-radius: 11px; padding: 12px; }
.kpi-val { font-size: 21px; font-weight: 750; letter-spacing: .3px; }
.kpi-unit { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-label { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }

.section-title { font-size: 14px; font-weight: 700; margin: 4px 0 2px; }
.headline {
  background: linear-gradient(135deg, #f3f6ff, #eef2ff);
  border: 1px solid #dbe3ff; border-radius: 12px; padding: 14px 16px;
}
.headline b { color: var(--brand-ink); }

/* Ranked steps */
.rank-list { display: flex; flex-direction: column; gap: 10px; }
.rank-card { border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; background: #fff; }
.rank-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 9px; }
.rank-badge {
  flex: none; font-size: 12px; font-weight: 700; color: #fff;
  border-radius: 7px; padding: 2px 8px;
}
.rank-name { font-weight: 650; font-size: 14.5px; flex: 1; }
.rank-time { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.bars { display: grid; grid-template-columns: 88px 1fr 44px; align-items: center; gap: 8px; margin: 5px 0; font-size: 12px; }
.bar-label { color: var(--ink-soft); }
.bar-track { height: 8px; border-radius: 99px; background: #eef1f7; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-soft); font-weight: 600; }

.rec { margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--line); font-size: 13px; color: var(--ink-soft); }
.rec b { color: var(--ink); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.tag { font-size: 11.5px; background: #f1f4fa; color: var(--ink-soft); border-radius: 6px; padding: 2px 8px; }

/* Roadmap */
.roadmap { display: flex; flex-direction: column; gap: 10px; }
.phase { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.phase-head { display: flex; align-items: center; gap: 9px; padding: 11px 14px; background: #fbfcff; border-bottom: 1px solid var(--line); }
.phase-dot { width: 10px; height: 10px; border-radius: 99px; flex: none; }
.phase-title { font-weight: 700; font-size: 13.5px; }
.phase-meta { margin-left: auto; font-size: 12px; color: var(--muted); }
.phase-body { padding: 11px 14px; }
.phase-body ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-soft); }
.phase-body li { margin-bottom: 5px; }
.phase-body li b { color: var(--ink); }
.phase-empty { font-size: 13px; color: var(--muted); }

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

/* Responsive */
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .report-panel { position: static; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 460px) {
  .wrap { width: calc(100% - 24px); }
  .metrics { grid-template-columns: 1fr 1fr; }
  .brand-sub { display: none; }
  .bars { grid-template-columns: 76px 1fr 40px; }
}

/* Print */
@media print {
  .topbar, .input-panel, .report-actions, .footer, .btn { display: none !important; }
  body { background: #fff; }
  .layout { display: block; padding: 0; }
  .report-panel { position: static; box-shadow: none; border: none; padding: 0; }
  .panel { box-shadow: none; }
}
