/* 管理员看板公共壳: 左侧导航 + 主内容区 */
:root {
  --bg: #eef2f6;
  --card: #ffffff;
  --border: #dce3ec;
  --text: #152033;
  --text2: #5a6a7e;
  --text3: #8b97a8;
  --primary: #0e7c6b;
  --primary-soft: #e6f5f1;
  --accent: #c45c26;
  --sidebar: #132033;
  --sidebar-2: #1a2b42;
  --sidebar-text: #b8c4d6;
  --sidebar-active: #0e7c6b;
  --danger: #c0392b;
  --ok: #1f8a5b;
  --sidebar-w: 220px;
}
* { margin:0; padding:0; box-sizing:border-box; }
html, body { height: 100%; }
html.admin-pending body {
  visibility: hidden;
}
html.admin-ready body {
  visibility: visible;
}
html.login-ready body {
  visibility: visible;
}
html.admin-pending:not(.admin-ready)::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: var(--bg, #eef2f6);
}
html.admin-pending:not(.admin-ready)::after {
  content: "加载中…";
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 9999;
  transform: translate(-50%, -50%);
  font-size: 14px;
  color: #5a6a7e;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }

.layout {
  display: flex;
  min-height: 100vh;
}

/* ---- 左侧导航 ---- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}
.sidebar-brand {
  padding: 22px 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand .logo-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #0e7c6b, #1aa88f);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff;
}
.sidebar-brand .sub {
  margin-top: 8px;
  font-size: 11px;
  color: var(--sidebar-text);
  opacity: .9;
}
.sidebar-nav {
  padding: 14px 10px;
  flex: 1;
  overflow: auto;
}
.nav-group {
  font-size: 11px;
  color: #7d8da3;
  padding: 10px 12px 6px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 2px 0;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
  background: rgba(14,124,107,.28);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--sidebar-active);
}
.nav-item .ico {
  width: 18px; text-align: center; opacity: .9; font-size: 14px;
}
.nav-item,
.nav-parent {
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav-item.admin-only { display: none; }
.nav-item.admin-only.show { display: flex; }

.nav-block { margin: 2px 0; }
.nav-parent {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  margin: 2px 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-parent:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-parent .ico { width: 18px; text-align: center; opacity: .9; font-size: 14px; flex-shrink: 0; }
.nav-parent .label { flex: 1; }
.nav-arrow {
  font-size: 11px;
  opacity: .65;
  transition: transform .2s ease;
}
.nav-block.open .nav-parent { color: #fff; }
.nav-block.open .nav-arrow { transform: rotate(180deg); opacity: .9; }
.nav-block.open .nav-parent.has-active,
.nav-block.open:has(.nav-sub.active) .nav-parent {
  background: rgba(14,124,107,.14);
}
.nav-children {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding: 0 0 0 8px;
  transition: max-height 0.22s ease, opacity 0.18s ease, padding 0.18s ease;
}
.nav-block.open .nav-children {
  max-height: 320px;
  opacity: 1;
  padding: 2px 0 4px 8px;
}
.nav-item.nav-sub {
  padding: 8px 12px 8px 10px;
  font-size: 13px;
  margin: 1px 0;
}
.nav-item.nav-sub .ico {
  width: 14px;
  font-size: 12px;
  opacity: .55;
}
.nav-item.nav-sub.active {
  background: rgba(14,124,107,.28);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--sidebar-active);
}

.sidebar-foot {
  padding: 14px 16px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px;
  color: var(--sidebar-text);
}
.sidebar-foot .user-line {
  color: #e8eef6;
  font-weight: 600;
  margin-bottom: 4px;
  word-break: break-all;
}
.sidebar-foot .role-line { margin-bottom: 10px; opacity: .85; }
.sidebar-foot .logout {
  display: inline-block;
  color: #9eb0c7;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
}
.sidebar-foot .logout:hover { color: #fff; border-color: rgba(255,255,255,.35); }

/* ---- 主区 ---- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar h1 {
  font-size: 17px;
  font-weight: 650;
  color: var(--text);
}
.topbar .right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--text2);
}
.conn { display:flex; align-items:center; gap:6px; }
.dot { width:8px; height:8px; border-radius:50%; background:#1f8a5b; display:inline-block; }
.dot.off { background:#c45c26; }

.content {
  padding: 18px 22px 40px;
  flex: 1;
}

/* 通用内容组件 */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(21,32,51,.04);
  margin-bottom: 14px;
}
.panel h3 {
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel h3 .hint { font-size: 12px; color: var(--text3); font-weight: normal; }
.hint { font-size: 12px; color: var(--text3); line-height: 1.55; margin-bottom: 12px; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.card .num { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card .lbl { color: var(--text2); font-size: 12px; }
.card .sub { color: var(--text3); font-size: 11px; margin-top: 3px; }
.card.blue .num { color: #1f6feb; }
.card.red .num { color: #c0392b; }
.card.green .num { color: #1f8a5b; }
.card.teal .num { color: #0e7c6b; }
.card.orange .num { color: #c45c26; }
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-bottom:14px; }
.grid3 { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; margin-bottom:14px; }
.filters { display:flex; flex-wrap:wrap; gap:10px; margin-bottom:14px; align-items:center; }
.filters select, .filters input, .form-row input, .form-row select, textarea {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  outline: none;
}
.filters select:focus, .form-row input:focus, textarea:focus { border-color: var(--primary); }
button, .btn {
  padding: 7px 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
button.ghost, .btn.ghost {
  background: #fff;
  color: var(--text2);
  border: 1px solid var(--border);
}
button.danger { background: var(--danger); }
table { width:100%; border-collapse:collapse; font-size:13px; }
th {
  text-align:left; color:var(--text3); font-weight:600;
  padding:8px 10px; border-bottom:1px solid var(--border); white-space:nowrap;
}
td { padding:8px 10px; border-bottom:1px solid #eef1f5; vertical-align:top; }
tr:hover td { background:#f7faf9; }
.badge {
  display:inline-block; padding:2px 9px; border-radius:10px;
  font-size:12px; color:#fff; white-space:nowrap;
}
.muted { color: var(--text3); }
.err { color: var(--danger); font-size:13px; margin-top:8px; min-height:18px; }
.ok { color: var(--ok); font-size:13px; margin-top:8px; }
.footer { color:var(--text3); font-size:12px; text-align:center; margin-top:20px; }
.tbl-scroll { max-height:520px; overflow:auto; }
.form-row { display:flex; flex-wrap:wrap; gap:10px; align-items:flex-end; margin-bottom:8px; }
.form-row label { display:flex; flex-direction:column; gap:4px; font-size:12px; color:var(--text2); }
.page-desc {
  background: var(--primary-soft);
  border: 1px solid #c5e8df;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12.5px;
  color: #24584e;
  margin-bottom: 14px;
  line-height: 1.55;
}

@media (max-width: 1100px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { width: 64px; }
  .sidebar-brand .logo span:not(.logo-mark),
  .sidebar-brand .sub,
  .nav-group,
  .nav-item span.label,
  .sidebar-foot .user-line,
  .sidebar-foot .role-line { display: none; }
  .nav-item { justify-content: center; padding: 12px 8px; }
  .sidebar-foot .logout { width: 100%; text-align: center; padding: 6px 0; }
}
