/* 后台样式：左固定导航 + 内容区，移动端折叠。 */
:root {
  --brand: #2563eb;
  --brand-soft: rgba(37, 99, 235, 0.1);
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

.layout { display: flex; min-height: 100vh; }

/* 侧栏 */
.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
}
.sidebar .logo img { width: 26px; height: 26px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 14px;
}
.nav a:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .foot { font-size: 11px; color: #64748b; padding: 0 10px; word-break: break-all; }

/* 主区 */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; }
.topbar .grow { flex: 1; }
.topbar .user { color: var(--muted); font-size: 13px; }
.content { padding: 20px 24px 48px; }

/* 卡片 / 布局 */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; display: flex; align-items: center; justify-content: space-between; }
.card .card-sub { color: var(--muted); font-size: 12px; margin: -6px 0 12px; }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.stat .hint { color: var(--muted); font-size: 12px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th, table.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.table th { color: var(--muted); font-weight: 600; font-size: 12px; background: #fbfcfe; }
table.table tbody tr:hover { background: #f9fbff; }
table.table td.wrap { white-space: normal; max-width: 280px; }
.empty { color: var(--muted); text-align: center; padding: 28px 10px; }

/* 徽标 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.6;
  background: #eef2f7;
  color: #475569;
}
.badge.success { background: rgba(22, 163, 74, 0.12); color: #15803d; }
.badge.pending { background: rgba(217, 119, 6, 0.12); color: #b45309; }
.badge.danger { background: rgba(220, 38, 38, 0.1); color: #b91c1c; }
.badge.info { background: var(--brand-soft); color: var(--brand); }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: var(--danger); border-color: rgba(220, 38, 38, 0.3); }
.btn.danger:hover { background: rgba(220, 38, 38, 0.06); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }

/* 表单 */
.form-grid { display: grid; gap: 14px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field .help { font-size: 12px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 84px; resize: vertical; }
input[type="checkbox"] { width: 16px; height: 16px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.code-box {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 9px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
  position: relative;
}
.copy { cursor: pointer; }

/* 工具栏 */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.toolbar input, .toolbar select { width: auto; min-width: 120px; }

/* 弹层 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}
.modal {
  background: var(--panel);
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.3);
  border: 1px solid var(--line);
}
.modal.wide { max-width: 860px; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; font-size: 15px; }
.modal .body { padding: 18px 20px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.modal .close { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--muted); }

/* 提示条 */
#toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast-item {
  padding: 9px 16px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: fade-in 0.18s ease;
}
.toast-item.error { background: var(--danger); }
.toast-item.success { background: var(--success); }
@keyframes fade-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* 图表 */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding-top: 8px; }
.chart .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.chart .bar .fill { width: 100%; max-width: 34px; background: linear-gradient(180deg, #60a5fa, #2563eb); border-radius: 6px 6px 2px 2px; min-height: 2px; transition: height 0.3s ease; }
.chart .bar .cap { font-size: 11px; color: var(--muted); }
.chart .bar .val { font-size: 11px; color: var(--text); }

/* 登录页 */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1000px 500px at 50% 0%, #dbeafe, transparent 60%), var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 28px 24px;
}
.login-card .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-weight: 700; font-size: 18px; }
.login-card .logo img { width: 30px; height: 30px; }
.login-card h1 { font-size: 16px; margin: 0 0 4px; }
.login-card p.sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; padding: 10px; font-size: 14px; }
.login-card .foot { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }

/* 安装向导 */
.install-tip { background: rgba(37, 99, 235, 0.08); border: 1px solid rgba(37, 99, 235, 0.2); padding: 10px 12px; border-radius: 10px; font-size: 13px; color: #1e40af; margin-bottom: 16px; }

@media (max-width: 1080px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .sidebar .logo { padding: 4px 8px; }
  .sidebar .spacer, .sidebar .foot { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav a { padding: 6px 10px; font-size: 13px; }
  .content { padding: 14px; }
  .topbar { padding: 12px 14px; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2, .form-grid.cols-2 { grid-template-columns: 1fr; }
}
