:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5b6775;
  --line: #d9e0e8;
  --accent: #0b6e4f;
  --accent-soft: #e6f4ef;
  --ssq: #c0392b;
  --dlt: #1f4e79;
  --warn: #9a6700;
  --danger: #9b1c1c;
  --radius: 12px;
  --shadow: 0 1px 0 rgba(16, 24, 40, 0.04);
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}
.brand .sub {
  color: var(--muted);
  font-size: 0.88rem;
}

.sync-bar .sync-bar-main {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.sync-bar .actions button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.sync-toast {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 0.92rem;
  word-break: break-word;
}
.sync-toast.info {
  background: #eef6ff;
  border-color: #c8ddf5;
  color: #1f4e79;
}
.sync-toast.ok {
  background: var(--accent-soft);
  border-color: #b7dfd0;
  color: var(--accent);
}
.sync-toast.err {
  background: #fde8e6;
  border-color: #f0c2bc;
  color: var(--danger);
}

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.nav a {
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
}
.nav a:hover { background: #eef2f6; }
.nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: #b7dfd0;
  font-weight: 600;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.card h2, .card h3 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.stat .v {
  font-size: 1.25rem;
  font-weight: 700;
}
.stat .l {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th, td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
}
tbody tr:hover { background: #f8fafc; }

.ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 700;
  margin-right: 4px;
  color: #fff;
}
.ball.red { background: var(--ssq); }
.ball.blue { background: #1d4ed8; }
.ball.front { background: var(--dlt); }
.ball.back { background: #0f766e; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #eef2f6;
  color: var(--muted);
}
.badge.ssq { background: #fde8e6; color: var(--ssq); }
.badge.dlt { background: #e8eef6; color: var(--dlt); }

.form {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
@media (max-width: 860px) {
  .form { grid-template-columns: 1fr 1fr; }
}
label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}
input, select, button {
  font: inherit;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}
button, .btn {
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
button:hover, .btn:hover { filter: brightness(0.95); }
.btn.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}
.actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.callout {
  border: 1px solid #f0d78c;
  background: #fff8e6;
  color: #6b4e00;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.callout strong { display: block; margin-bottom: 4px; }

.pattern {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fff;
}
.pattern .title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  margin-bottom: 6px;
}
.strength {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--muted);
}
.strength.mid { background: #e6f4ef; color: var(--accent); }
.strength.weak { background: #f3f4f6; color: #6b7280; }

.bars {
  display: grid;
  gap: 6px;
}
.bar-row {
  display: grid;
  grid-template-columns: 36px 1fr 42px;
  gap: 8px;
  align-items: center;
  font-size: 0.85rem;
}
.bar-track {
  height: 10px;
  background: #eef2f6;
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}
.bar-fill.blue { background: #1d4ed8; }

.pager {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.muted { color: var(--muted); }
.footer {
  margin-top: 24px;
  color: var(--muted);
  font-size: 0.82rem;
}

.scheme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 860px) {
  .scheme-grid { grid-template-columns: 1fr; }
}
.scheme-card .scheme-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.scheme-title {
  font-weight: 700;
}
.scheme-nums {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
}
.scheme-nums .plus {
  margin: 0 6px;
  color: var(--muted);
  font-weight: 700;
}

.primary-card {
  border-color: #9dceb8;
  background: #f7fcf9;
}
.primary-badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}
.ball.big {
  width: 34px;
  height: 34px;
  font-size: 0.9rem;
}
.primary-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.primary-meta span {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  color: var(--muted);
}
