:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f1f23;
  --muted: #8a8a8f;
  --primary: #4b6bfb;
  --primary-dark: #3a55d9;
  --border: #e8e8ee;
  --danger: #e5484d;
  --ok: #2f9e44;
  --warn: #e8890c;
}

* { box-sizing: border-box; }

/* 确保 hidden 属性始终生效（否则会被 .modal-mask/.login-view 的 display:flex 覆盖） */
[hidden] { display: none !important; }

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

/* ---------- 顶部栏 ---------- */
.topbar {
  background: #1f1f23;
  color: #fff;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip {
  font-size: 13px;
  color: #cfcfd6;
}

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* ---------- 登录 ---------- */
.login-view {
  display: flex;
  justify-content: center;
  padding-top: 80px;
}
.login-card {
  background: var(--card);
  border-radius: 16px;
  padding: 40px 36px;
  width: 380px;
  box-shadow: 0 8px 40px rgba(31, 31, 35, 0.08);
  text-align: center;
}
.login-title { margin: 0 0 6px; font-size: 22px; }
.login-sub { margin: 0 0 28px; color: var(--muted); font-size: 13px; }
.dev-login { margin-top: 24px; text-align: left; }
.divider-text {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 20px 0 14px;
  position: relative;
}
.divider-text::before, .divider-text::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 34%;
  height: 1px;
  background: var(--border);
}
.divider-text::before { left: 0; }
.divider-text::after { right: 0; }
.hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; line-height: 1.5; }

/* ---------- 面板 ---------- */
.panel {
  background: var(--card);
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 22px;
  box-shadow: 0 2px 14px rgba(31, 31, 35, 0.04);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.panel-title { margin: 0; font-size: 17px; }
.settings-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
}
.settings-row .field { flex: 1; margin: 0; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  text-align: left;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
}
.table td .link-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--primary);
}
.col-actions { width: 130px; }
.empty-hint {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}
.dept-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.dept-tag {
  background: #eef1ff;
  color: var(--primary);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
}

/* ---------- 状态徽标 ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 12px;
}
.badge-ok { background: #e7f6ec; color: var(--ok); }
.badge-expiring { background: #fdf1e3; color: var(--warn); }
.badge-expired { background: #fdeaea; color: var(--danger); }

/* ---------- 按钮 ---------- */
.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.btn:active { opacity: 0.85; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-danger-link { background: transparent; color: var(--danger); padding: 6px 8px; }
.btn-link { background: transparent; color: var(--primary); padding: 6px 8px; }
.btn-block { width: 100%; display: block; margin-top: 8px; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; margin-bottom: 6px; color: #55555c; }
.field-tip { display: block; font-size: 12px; color: var(--muted); margin-top: 5px; }
.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: #fff;
}
.input:focus { border-color: var(--primary); }
.error-text { color: var(--danger); font-size: 13px; margin: 8px 0 0; }

/* ---------- 部门选择 ---------- */
.dept-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}
.dept-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  font-size: 13px;
}
.dept-fallback textarea {
  width: 100%;
  min-height: 60px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  resize: vertical;
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(31, 31, 35, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: 14px;
  width: 480px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close {
  border: none;
  background: transparent;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.modal-body { padding: 22px 24px; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f1f23;
  color: #fff;
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}
