/* 后台框架样式：顶栏、侧边栏、表格、弹窗。登录页用 style.css，两者互不依赖。 */
:root {
  --bg: #0f1419;
  --card: #1a212b;
  --panel: #141b24;
  --border: #2a3441;
  --text: #e6e9ed;
  --muted: #8b97a5;
  --accent: #2dd4bf;
  --accent-dim: #14b8a6;
  --error: #f87171;
  --ok: #4ade80;
  --btn-text: #06211d;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}

/* ---- 顶栏 ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { font-weight: 600; color: inherit; text-decoration: none; }
.brand:hover { color: var(--accent); }

.menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  padding: 8px;
  cursor: pointer;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.username { color: var(--accent); font-size: 14px; }

.logout-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}

.logout-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---- 布局 ---- */
.layout { display: flex; min-height: calc(100vh - 52px); }

.sidebar {
  width: 180px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 10px 0;
  flex-shrink: 0;
  position: sticky;
  top: 52px;
  align-self: flex-start;
  height: calc(100vh - 52px);
  overflow-y: auto;
}

.nav-item {
  display: block;
  padding: 11px 18px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.nav-item:hover { color: var(--text); }

.nav-section {
  display: block;
  padding: 10px 18px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  border-top: 1px solid var(--border);
  margin-top: 6px;
}

.nav-item.on {
  color: var(--accent);
  background: #1f2a36;
  border-left: 2px solid var(--accent);
}

.overlay {
  position: fixed;
  inset: 52px 0 0 0;
  background: rgba(0, 0, 0, .5);
  z-index: 9;
}

.main { flex: 1; padding: 20px; min-width: 0; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.page-head h2 { font-size: 18px; }

/* ---- 按钮 ---- */
button.primary {
  background: var(--accent-dim);
  border: none;
  border-radius: 8px;
  color: var(--btn-text);
  font-size: 14px;
  font-weight: 600;
  /* 触控目标 ≈44px */
  padding: 11px 16px;
  cursor: pointer;
}

button.primary:hover { background: var(--accent); }
button.primary:disabled { opacity: .5; cursor: not-allowed; }

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 11px 16px;
  font-size: 14px;
  cursor: pointer;
}

button.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---- 表格 ---- */
.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }

th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th { color: var(--muted); font-weight: 500; background: var(--panel); font-size: 13px; }

tr:last-child td { border-bottom: none; }

button.link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 6px;
}

button.link.danger { color: var(--error); }

.cell-avatar { display: inline-flex; align-items: center; gap: 8px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-dim); color: #fff; font-size: 13px;
}
.muted-text { color: var(--muted); }

.empty { color: var(--muted); text-align: center; padding: 28px; font-size: 14px; }

/* ---- 弹窗 ---- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 16px;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 { font-size: 16px; margin-bottom: 14px; }

/* ---- 表单 ---- */
.field { margin-bottom: 13px; }

.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  /* ≥16px：防 iOS Safari 聚焦时自动放大页面 */
  font-size: 16px;
  padding: 10px 12px;
  outline: none;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 13px;
  cursor: pointer;
}

.check input { width: 18px; height: 18px; accent-color: var(--accent-dim); }

.error { color: var(--error); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

.msg-ok { color: var(--ok); font-size: 13px; margin-bottom: 8px; }

.modal-acts { display: flex; gap: 10px; justify-content: flex-end; }

.settings-form {
  max-width: 480px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.welcome-text { color: var(--muted); }

.hidden { display: none; }

/* ---- 移动端 ---- */
@media (max-width: 768px) {
  .menu-btn { display: block; }
  .sidebar {
    position: fixed;
    top: 52px;
    bottom: 0;
    left: 0;
    /* 抽屉层级抬到顶栏(z-index:20)之上,避免首个导航项「首页」被顶栏盖住看不到/点不到 */
    z-index: 25;
    transform: translateX(-100%);
    transition: transform .2s;
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 14px; }
  /* 弹窗手机端全屏化 */
  .modal-mask { padding: 0; align-items: stretch; }
  .modal { max-width: none; max-height: none; border-radius: 0; border: none; }
}

.crud-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.crud-search { min-width: 200px; padding: 8px 10px; }
.crud-toolbar select { padding: 8px 10px; }
.crud-filter-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.crud-filter-label select { color: var(--fg, inherit); }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.cell-truncate { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crud-pager { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-size: 14px; color: var(--muted); }
.crud-pager button { min-height: 40px; padding: 0 16px; }

/* ---- searchselect 可搜索下拉 ---- */
.ss-search { width: 100%; margin-bottom: 6px; }
