:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #07c160;
  --primary-dark: #06a552;
  --danger: #dc2626;
  --warn: #d97706;
  --sidebar: #1f2937;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1f2937 0%, #0f172a 100%);
}
.login-card {
  width: 360px;
  background: #fff;
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.login-card input {
  width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--primary); }
.login-err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 10px 0 0; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 208px; flex: 0 0 208px;
  background: var(--sidebar); color: #cbd5e1;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  padding: 22px 20px 18px; color: #fff; font-size: 16px; font-weight: 600;
  display: flex; flex-direction: column; gap: 4px;
}
.brand span { font-size: 12px; font-weight: 400; color: #94a3b8; }
#nav { flex: 1; padding: 6px 10px; display: flex; flex-direction: column; gap: 4px; }
#nav a {
  display: block; padding: 10px 12px; border-radius: 8px;
  color: #cbd5e1; text-decoration: none; font-size: 14px;
}
#nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
#nav a.active { background: var(--primary); color: #fff; }
.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255, 255, 255, .08); }
.who { font-size: 12px; color: #94a3b8; margin-bottom: 8px; line-height: 1.5; }

.main { flex: 1; padding: 26px 30px; min-width: 0; }
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 18px;
}
.page-head h2 { margin: 0; font-size: 20px; }

/* ---------- 表格 ---------- */
.table-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: auto;
}
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: 12px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #fafafa; color: var(--muted); font-weight: 500; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafcff; }
td.right, th.right { text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; line-height: 18px; white-space: nowrap;
}
.tag.green { background: #e7f8ee; color: #0f8a4d; }
.tag.gray { background: #f1f3f5; color: var(--muted); }
.tag.orange { background: #fff4e5; color: var(--warn); }
.tag.red { background: #feeceb; color: var(--danger); }
.tag.blue { background: #e8f1ff; color: #2563eb; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
  padding: 9px 16px; font-size: 13px; font-family: inherit;
  background: #eef1f4; color: var(--text); transition: .15s;
}
.btn:hover { filter: brightness(.96); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn.danger { background: #fff; border-color: #f3c9c9; color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; padding: 11px; }
.btn.link { background: none; border: none; color: #2563eb; padding: 4px 6px; }
.btn.link.danger { color: var(--danger); }
.icon-btn {
  background: none; border: none; cursor: pointer; font-size: 20px;
  color: var(--muted); line-height: 1; padding: 4px 8px;
}
.actions { display: flex; gap: 2px; justify-content: flex-end; white-space: nowrap; }

.filters { display: flex; gap: 8px; align-items: center; }
.filters select, select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-family: inherit; font-size: 13px;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow: auto; z-index: 50;
}
.modal-box {
  background: #fff; border-radius: 12px; width: 720px; max-width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
}
.modal-box.narrow { width: 460px; }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 16px; }

/* ---------- 表单 ---------- */
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px;
  padding: 18px 20px 20px;
}
.form-grid.one { grid-template-columns: 1fr; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form-grid input, .form-grid select {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; font-family: inherit; color: var(--text); background: #fff;
}
.form-grid input:focus, .form-grid select:focus { outline: none; border-color: var(--primary); }
.form-grid .full { grid-column: 1 / -1; }
.form-foot { display: flex; justify-content: flex-end; gap: 10px; }
.hint { color: var(--muted); font-size: 12px; }
.expire-quick { display: flex; gap: 6px; align-items: flex-end; padding-bottom: 2px; }
.cert-box {
  border: 1px dashed var(--line); border-radius: 8px;
  padding: 12px 14px; background: #fafbfc;
}
.cert-title { font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.cert-status { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.cert-files { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.cert-files input[type=file] { font-size: 12px; max-width: 200px; }
.perm-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.perm-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.perm-list { display: flex; flex-direction: column; gap: 8px; }
.perm-list label { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
.perm-list input { width: 15px; height: 15px; }

/* ---------- 账号 ---------- */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.card.narrow { max-width: 420px; }
.card h3 { margin: 0 0 14px; font-size: 15px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 10px 20px; border-radius: 999px;
  font-size: 13px; z-index: 100; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.toast.err { background: #b91c1c; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  #nav { flex-direction: row; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .main { padding: 16px; }
}
