/* ========== Dashboard 风格（style-tokens.md 落地） ========== */
:root {
  --dp: #111827;
  --ds: #f9fafb;
  --da: #6366f1;
  --dgreen: #10b981;
  --dyellow: #f59e0b;
  --dred: #ef4444;
  --dborder: #e5e7eb;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--ds);
  color: var(--dp);
  font-size: 14px;
}
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* ========== 布局 ========== */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: #111827;
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { padding: 18px 20px; font-weight: 600; letter-spacing: -0.01em; font-size: 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; width: 100%; text-align: left;
  color: #d1d5db; background: none; border: none;
  font-size: 14px; transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.active { background: rgba(255, 255, 255, 0.1); color: #fff; font-weight: 600; }
.sidebar .side-foot { margin-top: auto; padding: 14px 20px; border-top: 1px solid rgba(255,255,255,0.1); color: #9ca3af; font-size: 12px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.toolbar {
  background: #fff; border-bottom: 1px solid var(--dborder);
  padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; z-index: 10;
}
.toolbar h1 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.content { flex: 1; padding: 24px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* ========== 卡片 / KPI ========== */
.card { background: #fff; border: 1px solid #f3f4f6; border-radius: 12px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); padding: 20px; }
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; letter-spacing: -0.01em; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi { background: #fff; border: 1px solid #f3f4f6; border-radius: 12px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); padding: 18px 20px; transition: box-shadow 0.15s, transform 0.15s; }
.kpi:hover { box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08); transform: translateY(-1px); }
.kpi .label { color: #6b7280; font-size: 13px; }
.kpi .num { font-size: 28px; font-weight: 600; margin-top: 6px; letter-spacing: -0.02em; }
.kpi .sub { font-size: 12px; color: #9ca3af; margin-top: 4px; }
.kpi .num.green { color: var(--dgreen); }
.kpi .num.yellow { color: var(--dyellow); }
.kpi .num.red { color: var(--dred); }

/* ========== 按钮 / 输入框 ========== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-weight: 500; font-size: 14px; border: none; transition: all 0.15s; }
.btn-primary { background: var(--da); color: #fff; }
.btn-primary:hover { background: #4f46e5; }
.btn-secondary { background: #f3f4f6; color: #374151; }
.btn-secondary:hover { background: #e5e7eb; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.input, .textarea, .select {
  width: 100%; background: #f9fafb; border: 1px solid var(--dborder); border-radius: 8px;
  padding: 8px 12px; font-size: 14px; color: var(--dp); transition: all 0.2s; outline: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--da); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2); background: #fff; }
.textarea { resize: vertical; min-height: 90px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-field label { display: block; font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 6px; }
.form-field .hint { font-size: 12px; color: #9ca3af; margin-top: 4px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ========== 表格 ========== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 10px 12px; color: #6b7280; font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--dborder); }
.table td { padding: 12px; border-bottom: 1px solid #f3f4f6; }
.table tbody tr { transition: background 0.15s; }
.table tbody tr:hover { background: #f9fafb; }
.table .ops { display: flex; gap: 8px; }

/* ========== 状态提示 ========== */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; margin-top: 16px; }
.alert-ok { background: #d1fae5; color: #065f46; }
.alert-err { background: #fee2e2; color: #991b1b; }

.empty-tip { text-align: center; color: #9ca3af; padding: 40px 0; }

.menu-btn { display: none; }

/* ========== 响应式 ========== */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar {
    position: fixed; inset: 0; width: 240px; z-index: 40;
    transform: translateX(-100%); transition: transform 0.2s;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(17, 24, 39, 0.4); z-index: 35; }
  .kpi-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .toolbar { padding: 10px 16px; }
  .menu-btn { display: inline-flex; }
  /* 移动端顶栏精简：隐藏邮箱文本，避免与返回/退出按钮挤在一起 */
  #toolbarEmail { display: none; }
}
