/* 后台与安装页：黑 / 白 / 灰 */

:root {
  --bg: #ffffff;
  --surface: #f4f4f5;
  --border: #e4e4e7;
  --text: #0a0a0a;
  --muted: #71717a;
  --black: #0a0a0a;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

body.login-page {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
}

.login-card h1 {
  margin: 0 0 1.25rem;
  font-size: 1.35rem;
  font-weight: 600;
}

.form label {
  display: block;
  margin: 0.75rem 0 0.35rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.form input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.form input:focus {
  outline: 2px solid #d4d4d8;
  outline-offset: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--black);
  cursor: pointer;
  font-size: 0.95rem;
  text-decoration: none;
}

.btn-primary {
  background: var(--black);
  color: var(--white);
}

.btn-primary:hover {
  background: #27272a;
}

.btn-block {
  width: 100%;
  margin-top: 1rem;
}

.alert {
  padding: 0.65rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: #fafafa;
  border: 1px solid var(--border);
  color: var(--text);
}

.alert-success {
  background: #fafafa;
  border: 1px solid #d4d4d8;
  color: var(--text);
}

.admin-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, margin 0.2s ease;
}

.sidebar.is-collapsed {
  width: 72px;
}

.sidebar.is-collapsed .sidebar-brand {
  text-align: center;
  padding: 1rem 0.35rem;
  font-size: 0.8rem;
  line-height: 1.2;
}

.sidebar.is-collapsed .sidebar-nav {
  flex-direction: column;
  overflow-x: visible;
  padding: 0.5rem 0.35rem;
}

.sidebar.is-collapsed .nav-item {
  flex: 0 0 auto;
  width: 100%;
  text-align: center;
  padding: 0.45rem 0.2rem;
  font-size: 0.68rem;
  line-height: 1.25;
  white-space: normal;
}

.sidebar-brand {
  padding: 1rem 1.25rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.sidebar-nav {
  padding: 0.55rem 0.45rem;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.25rem;
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-item {
  display: block;
  flex: 1 1 0;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.55rem 0.25rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.72rem;
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  z-index: 0;
}

.nav-item:hover {
  background: #e4e4e7;
}

.nav-item.is-active {
  background: var(--black);
  color: var(--white);
}

.sidebar-collapse {
  margin: 0.5rem;
  margin-top: auto;
  padding: 0.5rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}

.sidebar-collapse:hover {
  background: var(--surface);
}

.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.topbar-spacer {
  flex: 1;
}

.icon-btn {
  display: none;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
}

.user-menu {
  position: relative;
}

.user-name {
  display: inline-block;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: default;
  font-size: 0.9rem;
  color: var(--text);
  border: 1px solid transparent;
}

.user-menu:hover .user-name,
.user-menu:focus-within .user-name {
  border-color: var(--border);
  background: var(--surface);
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  min-width: 140px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
  padding: 0.35rem 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 50;
}

.user-menu:hover .user-dropdown,
.user-menu:focus-within .user-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-dropdown a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.875rem;
}

.user-dropdown a:hover {
  background: var(--surface);
}

.content {
  flex: 1;
  padding: 1.5rem 1.25rem;
  background: var(--bg);
}

.page-head h2 {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.card-stat {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  background: var(--bg);
}

.card-stat-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.card-stat-value {
  margin-top: 0.35rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.form-narrow {
  max-width: 420px;
}

.input-disabled {
  opacity: 0.75;
  background: var(--surface);
}

code {
  background: var(--surface);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.doc-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0 0 1.25rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.doc-toc a {
  color: var(--text);
  font-size: 0.875rem;
  text-decoration: none;
}

.doc-toc a:hover {
  text-decoration: underline;
}

.doc-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.25rem;
  background: var(--bg);
}

.doc-block-title {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.doc-lead {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  line-height: 1.55;
}

.doc-sub {
  margin: 1rem 0 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.doc-pre {
  margin: 0.35rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.45;
}

.doc-pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 0.35rem 0 0;
}

.doc-table th,
.doc-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

.doc-table thead th {
  background: var(--surface);
  font-weight: 600;
}

.doc-list {
  margin: 0.35rem 0 0;
  padding-left: 1.25rem;
  line-height: 1.6;
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .icon-btn.mobile-only {
    display: inline-block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .admin-body.sidebar-mobile-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 90;
  }
}
