:root {
  --bg: #f3f1ec;
  --panel: #fffdf8;
  --ink: #1c2430;
  --muted: #5e6a78;
  --line: #ddd6c8;
  --accent: #e85d04;
  --accent-2: #1b6b5a;
  --good: #1b6b5a;
  --warn: #b45309;
  --bad: #b42318;
  --shadow: 0 10px 30px rgba(28, 36, 48, 0.06);
  --radius: 14px;
  --font: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", sans-serif;
  --display: "Fraunces", "Noto Serif SC", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(232, 93, 4, 0.10), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(27, 107, 90, 0.08), transparent 55%),
    var(--bg);
  min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  background: #162029;
  color: #e8eef4;
  padding: 28px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  font-family: var(--display);
  font-size: 1.35rem;
  line-height: 1.2;
  margin: 0 0 6px;
}
.brand span { color: #ff9f1c; }
.side .tag {
  color: #9fb0c0;
  font-size: 0.78rem;
  margin-bottom: 28px;
}
.nav-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}
.nav-row .tip { flex: 0 0 auto; }
.nav a {
  display: block;
  flex: 1;
  color: #d7e0ea;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
}
.nav a:hover, .nav a.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
}
.side-foot {
  margin-top: 36px;
  font-size: 0.82rem;
  color: #8fa0b0;
}
.side-foot a { color: #ffb703; }

.main { padding: 28px 32px 48px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 22px;
}
.topbar h1 {
  font-family: var(--display);
  font-size: 1.7rem;
  margin: 0 0 4px;
  font-weight: 600;
}
.topbar p { margin: 0; color: var(--muted); font-size: 0.92rem; }

.flash {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  background: #fff;
}
.flash.ok { border-color: #b7d7cf; background: #eef8f5; color: var(--good); }
.flash.err { border-color: #f0c2bd; background: #fff1ef; color: var(--bad); }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 1.2fr 0.8fr; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card h2, .card h3 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-family: var(--display);
  font-weight: 600;
}
.stat-label { color: var(--muted); font-size: 0.8rem; }
.stat-value {
  font-family: var(--display);
  font-size: 1.6rem;
  margin-top: 4px;
  font-weight: 600;
}
.stat-sub { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: rgba(232, 93, 4, 0.03); }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #eee7db;
  color: #4b5563;
}
.badge.self { background: #ffe3c4; color: #9a3412; }
.badge.good { background: #d8f3ea; color: #0f5c4c; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.92rem;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: #fff; color: var(--ink); }
.btn-teal { background: var(--accent-2); }
.btn-sm { padding: 6px 10px; font-size: 0.82rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  color: var(--ink);
}
.form-row { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.auth-card h1 {
  font-family: var(--display);
  margin: 0 0 6px;
  font-size: 1.6rem;
}
.auth-card .sub { color: var(--muted); margin: 0 0 20px; font-size: 0.9rem; }
.auth-card .links { margin-top: 14px; font-size: 0.88rem; color: var(--muted); }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 140px;
  padding-top: 8px;
}
.chart .bar {
  flex: 1;
  background: linear-gradient(180deg, #ff9f1c, #e85d04);
  border-radius: 6px 6px 2px 2px;
  min-height: 4px;
  position: relative;
}
.chart .bar span {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
}
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }

/* 问号算法提示 */
.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 4px;
  cursor: help;
}
.tip-mark {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #b7c0cb;
  color: #5e6a78;
  background: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  font-family: var(--font);
  user-select: none;
}
.tip:hover .tip-mark,
.tip:focus .tip-mark,
.tip:focus-within .tip-mark {
  border-color: var(--accent);
  color: var(--accent);
  background: #fff7ed;
}
.tip-bubble {
  position: absolute;
  z-index: 40;
  width: max-content;
  max-width: 280px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #1c2430;
  color: #f5f7fa;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.55;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  box-shadow: 0 12px 28px rgba(0,0,0,0.18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .15s ease, visibility .15s ease;
  white-space: normal;
}
.tip-bubble::after {
  content: "";
  position: absolute;
  border: 6px solid transparent;
}
.tip-top .tip-bubble {
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
}
.tip-top .tip-bubble::after {
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-top-color: #1c2430;
}
.tip-bottom .tip-bubble {
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
}
.tip-bottom .tip-bubble::after {
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-bottom-color: #1c2430;
}
.tip-left .tip-bubble {
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
}
.tip-left .tip-bubble::after {
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border-left-color: #1c2430;
}
.tip-right .tip-bubble {
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
}
.tip-right .tip-bubble::after {
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border-right-color: #1c2430;
}
.tip:hover .tip-bubble,
.tip:focus .tip-bubble,
.tip:focus-within .tip-bubble {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
/* 触屏：点击问号也可展开 */
.tip.is-open .tip-bubble {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.stat-label .tip,
label .tip,
h1 .tip,
h2 .tip,
h3 .tip,
th .tip {
  margin-left: 5px;
}
.side .tip-mark {
  border-color: #6b7c8c;
  color: #c5d0db;
  background: transparent;
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: relative; height: auto; }
  .grid-4, .grid-3, .grid-2, .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .main { padding: 18px 14px 36px; }
  .grid-4, .grid-3, .grid-2, .form-grid { grid-template-columns: 1fr; }
}
