:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --primary: #3b82f6;
  --primary-d: #2563eb;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --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;
}
a { color: var(--primary); text-decoration: none; }

/* 登录页 */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 360px;
  background: var(--panel);
  border-radius: 14px;
  padding: 32px 30px;
  box-shadow: 0 10px 40px rgba(0,0,0,.08);
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: #0f172a;
  color: #cbd5e1;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.sidebar .brand {
  padding: 18px 20px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar a {
  display: block;
  padding: 12px 20px;
  color: #cbd5e1;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar a.active {
  background: rgba(59,130,246,.18);
  color: #fff;
  border-left-color: var(--primary);
}
.sidebar .spacer { flex: 1; }
.sidebar .me {
  padding: 14px 20px;
  font-size: 12px;
  color: #94a3b8;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar .me b { color: #e2e8f0; }

.main { flex: 1; padding: 24px 28px; overflow-x: auto; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.topbar h2 { margin: 0; font-size: 20px; }
.btn {
  display: inline-block;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}
.btn:hover { background: var(--primary-d); }
.btn.gray { background: #e5e7eb; color: #333; }
.btn.gray:hover { background: #d1d5db; }
.btn.red { background: var(--red); }
.btn.red:hover { background: #b91c1c; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.green { background: var(--green); }
.btn.green:hover { background: #15803d; }

/* 卡片 / 统计 */
.stats { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px 20px;
  flex: 1;
  min-width: 130px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.stat .num { font-size: 26px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* 面板 / 表格 */
.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  margin-bottom: 18px;
}
.panel h3 { margin: 0 0 14px; font-size: 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 600; background: #fafbfc; }
tr:hover td { background: #f9fafb; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; vertical-align: middle; }

/* 标签 */
.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; }
.tag.normal { background: #e7f6ec; color: var(--green); }
.tag.near   { background: #fef3e2; color: var(--amber); }
.tag.expired{ background: #fdeaea; color: var(--red); }
.tag.on  { background: #e7f0ff; color: var(--primary); }
.tag.off { background: #f1f1f1; color: #888; }
.tag.ok  { background: #e7f6ec; color: var(--green); }
.tag.no  { background: #f1f1f1; color: #999; }

/* 表单 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
}
.row2 { display: flex; gap: 12px; }
.row2 > div { flex: 1; }

/* 到期时长：数量 + 单位，快捷选择 + 实时预览 */
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.quick .btn { padding: 4px 10px; font-size: 12px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; line-height: 1.6; word-break: break-all; }
.hint.warn { color: var(--amber); }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: none; align-items: center; justify-content: center;
  z-index: 50;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px;
  width: 460px; max-width: 92vw;
  padding: 22px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal h3 { margin: 0 0 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* 提示 */
.toast {
  position: fixed; top: 20px; left: 50%;
  transform: translateX(-50%);
  background: #111827; color: #fff;
  padding: 11px 18px; border-radius: 8px;
  font-size: 14px; z-index: 99;
  opacity: 0; transition: opacity .2s; pointer-events: none;
  max-width: min(760px, 92vw);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 8px 26px rgba(0,0,0,.22);
}
.toast.show { opacity: .97; }
.toast.err { background: #b91c1c; cursor: pointer; pointer-events: auto; }
.toast.ok { background: #15803d; }

.empty { color: var(--muted); text-align: center; padding: 30px; }

@media (max-width: 720px) {
  .sidebar { width: 60px; }
  .sidebar a, .sidebar .brand, .sidebar .me { font-size: 0; padding: 14px 0; text-align: center; }
  .sidebar a::first-letter, .sidebar .brand::first-letter { font-size: 16px; }
  .main { padding: 16px; }
  .row2 { flex-direction: column; }
}
