:root {
  --sp-bg: #f5f6f5;
  --sp-surface: #ffffff;
  --sp-surface-muted: #f8f9f8;
  --sp-ink: #202522;
  --sp-ink-2: #5f6863;
  --sp-ink-3: #929b96;
  --sp-line: #dfe4e1;
  --sp-line-soft: #edf0ee;
  --sp-green: #176b52;
  --sp-green-strong: #10543f;
  --sp-green-soft: #e9f3ef;
  --sp-gold: #a57a2c;
  --sp-gold-soft: #f7f0df;
  --sp-amber: #a86816;
  --sp-amber-soft: #fff3df;
  --sp-red: #a74439;
  --sp-red-soft: #faece9;
  --sp-radius: 6px;
  --sp-header-h: 60px;
}

* { box-sizing: border-box; }
body.sp-internal {
  margin: 0;
  background: var(--sp-bg);
  color: var(--sp-ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}
body.sp-internal button,
body.sp-internal input,
body.sp-internal textarea,
body.sp-internal select { font: inherit; letter-spacing: 0; }
body.sp-internal a { color: inherit; }

.sp-app-header {
  height: var(--sp-header-h);
  flex: 0 0 var(--sp-header-h);
  display: flex;
  align-items: stretch;
  gap: 28px;
  padding: 0 22px;
  background: var(--sp-surface);
  border-bottom: 1px solid var(--sp-line);
  position: relative;
  z-index: 30;
}
.sp-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  text-decoration: none;
}
.sp-brand-cn {
  font-family: "Songti SC", "STSong", serif;
  font-size: 20px;
  font-weight: 800;
}
.sp-brand-sub { color: var(--sp-ink-3); font-size: 12px; }
.sp-primary-nav { display: flex; align-items: stretch; gap: 24px; }
.sp-primary-nav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-bottom: 2px solid transparent;
  color: var(--sp-ink-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}
.sp-primary-nav a:hover { color: var(--sp-ink); }
.sp-primary-nav a.active { color: var(--sp-green); border-bottom-color: var(--sp-green); }
.sp-primary-nav svg { width: 17px; height: 17px; stroke-width: 1.8; }
.sp-header-spacer { flex: 1; }
.sp-header-meta { display: flex; align-items: center; gap: 10px; }
.sp-sync {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--sp-ink-2);
  font-size: 12px;
  white-space: nowrap;
}
.sp-sync svg { width: 15px; height: 15px; color: var(--sp-green); }
.sp-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-left: 10px;
  border-left: 1px solid var(--sp-line);
  color: var(--sp-ink-2);
  font-size: 12px;
  white-space: nowrap;
}
.sp-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--sp-green);
  color: white;
  font-weight: 800;
}

.sp-mobile-nav { display: none; }
.sp-page { min-height: calc(100vh - var(--sp-header-h)); }
.sp-page-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  background: var(--sp-surface);
  border-bottom: 1px solid var(--sp-line);
}
.sp-page-heading { min-width: 0; }
.sp-page-heading h1 { margin: 0; font-size: 22px; line-height: 1.3; }
.sp-page-heading p { margin: 4px 0 0; color: var(--sp-ink-3); font-size: 12px; }
.sp-page-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.sp-button,
.sp-icon-button {
  border: 1px solid var(--sp-line);
  border-radius: var(--sp-radius);
  background: var(--sp-surface);
  color: var(--sp-ink-2);
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  text-decoration: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}
.sp-icon-button { width: 36px; padding: 0; }
.sp-button:hover,.sp-icon-button:hover { border-color: #bdc8c2; color: var(--sp-ink); }
.sp-button.primary { background: var(--sp-green); color: #fff; border-color: var(--sp-green); }
.sp-button.primary:hover { background: var(--sp-green-strong); }
.sp-button.danger { color: var(--sp-red); border-color: #e4b9b3; }
.sp-button svg,.sp-icon-button svg { width: 16px; height: 16px; stroke-width: 1.9; }

.sp-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--sp-green-soft);
  color: var(--sp-green);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.sp-status.warn { background: var(--sp-amber-soft); color: var(--sp-amber); }
.sp-status.danger { background: var(--sp-red-soft); color: var(--sp-red); }
.sp-muted { color: var(--sp-ink-3); }
.sp-input,
.sp-select {
  min-height: 38px;
  border: 1px solid var(--sp-line);
  border-radius: var(--sp-radius);
  background: var(--sp-surface);
  color: var(--sp-ink);
  padding: 8px 10px;
  outline: none;
}
.sp-input:focus,.sp-select:focus { border-color: var(--sp-green); box-shadow: 0 0 0 2px rgba(23,107,82,.1); }
.sp-divider { border: 0; border-top: 1px solid var(--sp-line-soft); margin: 0; }

@media (max-width: 820px) {
  :root { --sp-header-h: 54px; }
  body.sp-internal { padding-bottom: 60px; }
  .sp-app-header { height: 54px; padding: 0 12px; gap: 10px; }
  .sp-brand-cn { font-size: 18px; }
  .sp-brand-sub,.sp-primary-nav,.sp-user { display: none; }
  .sp-header-meta { margin-left: auto; }
  .sp-sync span { display: none; }
  .sp-mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(58px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: grid;
    grid-template-columns: repeat(4,1fr);
    background: rgba(255,255,255,.97);
    border-top: 1px solid var(--sp-line);
    z-index: 50;
  }
  .sp-mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--sp-ink-3);
    text-decoration: none;
    font-size: 10px;
    font-weight: 700;
  }
  .sp-mobile-nav a.active { color: var(--sp-green); }
  .sp-mobile-nav svg { width: 20px; height: 20px; stroke-width: 1.8; }
  .sp-page { min-height: calc(100vh - 112px); }
  .sp-page-header { min-height: 64px; padding: 10px 12px; }
  .sp-page-heading h1 { font-size: 19px; }
  .sp-page-actions .sp-button span.optional { display: none; }
}
