:root {
  --bg: #f2f4f7;
  --panel: #ffffff;
  --line: #e6e9ef;
  --text: #1c2430;
  --muted: #6b7788;
  --accent: #0a84ff;
  --accent-soft: #e9f2ff;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --ok: #12a150;
  --ok-soft: #e8f7ee;
  --warn: #b7791f;
  --side: #101826;
  --side-text: #c3cedb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #dbe7ff 0%, #f2f4f7 55%, #eef1f6 100%);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px; box-shadow: 0 18px 50px rgba(16, 24, 40, .12);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand b { display: block; font-size: 17px; }
.login-brand small { color: var(--muted); font-size: 12px; }
.logo {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #4f8bff, #8fb6ff); color: #fff; font-weight: 800; font-size: 18px;
}
.login-card label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.login-card input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: #fbfcfe; font-size: 15px; color: var(--text); outline: none;
}
.login-card input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card button {
  width: 100%; margin-top: 20px; padding: 12px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600;
}
.login-card button:disabled { opacity: .7; }
.login-msg { min-height: 20px; margin: 12px 0 0; font-size: 13px; color: var(--danger); }
.login-tip { margin: 6px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- 布局 ---------- */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-text); padding: 18px 14px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; color: #fff; }
.side .brand b { display: block; font-size: 15px; }
.side .brand small { color: #7c8b9f; font-size: 11px; }
.side .logo { width: 34px; height: 34px; border-radius: 10px; font-size: 15px; }
#nav { display: flex; flex-direction: column; gap: 2px; overflow: auto; }
#nav a {
  padding: 9px 12px; border-radius: 9px; color: var(--side-text); font-size: 13.5px; cursor: pointer;
}
#nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
#nav a.on { background: rgba(10, 132, 255, .9); color: #fff; font-weight: 600; }
.side-foot {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12.5px;
}
.side-foot .ghost { background: transparent; border: 1px solid rgba(255,255,255,.2); color: var(--side-text); }

.main { padding: 22px 26px 40px; min-width: 0; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.topbar h1 { margin: 0; font-size: 21px; letter-spacing: -.2px; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.mini {
  padding: 5px 10px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line);
  color: var(--muted); font-size: 12.5px;
}
.mini:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.clock { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* 工具栏 */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select {
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel);
  font-size: 13.5px; color: var(--text); outline: none;
}
.toolbar input { min-width: 220px; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--accent); }
.toolbar .spacer { flex: 1; }

.btn {
  padding: 8px 14px; border-radius: 9px; border: 1px solid transparent; background: var(--accent);
  color: #fff; font-size: 13px; font-weight: 600;
}
.btn:hover { filter: brightness(1.05); }
.btn.ghost { background: var(--panel); color: var(--text); border-color: var(--line); }
.btn.danger { background: var(--danger); }
.btn.tiny { padding: 4px 9px; font-size: 12px; font-weight: 500; }
button.ghost.tiny { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
button.danger.tiny { background: var(--danger-soft); color: var(--danger); border: 1px solid transparent; }
button.okmini { background: var(--ok-soft); color: var(--ok); border: 1px solid transparent; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* 卡片与表格 */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card + .card { margin-top: 16px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card-head {
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-weight: 600; font-size: 14px;
}
.card-body { padding: 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .k { color: var(--muted); font-size: 12.5px; }
.stat .v { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #fafbfd; color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: #fafcff; }
tbody tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; display: flex; gap: 6px; flex-wrap: wrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); }
.clip { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: #eef1f6; vertical-align: middle; }
.who { display: flex; align-items: center; gap: 8px; }
.who b { font-weight: 600; font-size: 13px; }
.who small { display: block; color: var(--muted); font-size: 11.5px; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.badge.gray { background: #eef1f6; color: var(--muted); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.green { background: var(--ok-soft); color: var(--ok); }
.badge.amber { background: #fdf3e3; color: var(--warn); }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 14px; font-size: 13px; color: var(--muted); }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 13.5px; }
.loading { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 13.5px; }

.forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: #fbfcfe; font-size: 13.5px; font-family: inherit; color: var(--text); outline: none;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); background: #fff; }
.field.full { grid-column: 1 / -1; }
.switches { display: flex; flex-wrap: wrap; gap: 14px; padding: 4px 0; }
.switches label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.switches input { width: 15px; height: 15px; }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(10, 18, 30, .45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal-box { width: 100%; max-width: 620px; max-height: 88vh; background: var(--panel); border-radius: 14px; overflow: auto; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }
.icon { background: transparent; border: 0; font-size: 22px; line-height: 1; color: var(--muted); }

/* 提示 */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px);
  background: #101826; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: .22s ease; z-index: 60; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #b3261e; }

/* 手机 */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: column; padding: 12px; }
  #nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  #nav a { white-space: nowrap; padding: 7px 11px; }
  .side .brand { padding-bottom: 12px; }
  .side-foot { border-top: 0; padding-top: 8px; }
  .main { padding: 16px 14px 32px; }
  .topbar { flex-direction: column; gap: 8px; }
  .toolbar input { min-width: 0; width: 100%; }
  table { font-size: 12.5px; }
  th, td { padding: 8px 9px; }
  .clip { max-width: 200px; }
}
