:root {
  --bg: #f6f7f9;
  --text: #172033;
  --muted: #667085;
  --line: #d9dee7;
  --panel: #ffffff;
  --primary: #e11d48;
  --primary-dark: #be123c;
  --blue: #2563eb;
  --green: #16a34a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: inherit; text-decoration: none; }
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-size: 22px; font-weight: 800; color: var(--primary); }
.topbar nav { display: flex; gap: 18px; color: var(--muted); font-weight: 600; }
.page { max-width: 1180px; margin: 0 auto; padding: 28px 20px 48px; }
.hero, .admin-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 24px;
}
.eyebrow { margin: 0 0 8px; color: var(--primary); font-weight: 700; }
h1 { margin: 0; font-size: 34px; line-height: 1.2; }
h2 { margin: 0; font-size: 18px; }
.hero p:not(.eyebrow) { color: var(--muted); margin: 10px 0 0; }
.filters, .actions { display: flex; gap: 10px; align-items: center; }
.filters select { min-width: 116px; }
select, input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}
button, .link-button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
button:hover { background: var(--primary-dark); }
.ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}
.danger { background: #991b1b; min-height: 32px; }
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.metrics article, .panel, .login-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(23, 32, 51, 0.05);
}
.metrics article { padding: 18px; }
.metrics span, .panel-head span { color: var(--muted); font-size: 13px; }
.metrics strong { display: block; margin-top: 8px; font-size: 28px; }
.chart-section { margin-bottom: 18px; }
.panel { padding: 18px; margin-bottom: 18px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.chart-panel { min-width: 0; }
.chart-canvas-wrap {
  height: 310px;
  width: 100%;
  position: relative;
}
.chart-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 13px;
}
.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}
.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.legend-dot.personal { background: var(--primary); }
.legend-dot.average { background: var(--blue); }
.legend-dot.top { background: var(--green); }
.gap-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.gap-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fafbfc;
}
.gap-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.gap-summary strong {
  font-size: 18px;
  color: var(--text);
}
.gap-summary strong.positive { color: var(--green); }
.gap-summary strong.negative { color: var(--primary); }
.gap-summary p {
  grid-column: 1 / -1;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.insights { margin: 0; padding-left: 20px; color: #344054; line-height: 1.8; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 700; background: #fafbfc; }
.empty { text-align: center; color: var(--muted); padding: 28px; }
.login-box { max-width: 420px; margin: 80px auto; padding: 28px; }
.login-box p { color: var(--muted); }
.login-box form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.alert {
  background: #fff1f2;
  color: #9f1239;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.score-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.score-form .wide { grid-column: span 2; }
.score-form .actions { align-self: end; }
.row-actions { display: flex; gap: 10px; align-items: center; }
.row-actions form { margin: 0; }

@media (max-width: 820px) {
  .hero, .admin-head { align-items: stretch; flex-direction: column; }
  .filters, .metrics, .score-form { grid-template-columns: 1fr; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters select[name="mode"] { grid-column: 1 / -1; }
  .metrics { display: grid; }
  .score-form .wide { grid-column: span 1; }
  h1 { font-size: 28px; }
  .topbar { padding: 0 16px; }
  .chart-canvas-wrap { height: 260px; }
  .chart-legend { gap: 6px; }
  .chart-legend span { font-size: 12px; padding: 4px 7px; }
}
