* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --line: #e6e9ef;
  --text: #1f2733;
  --muted: #6b7686;
  --primary: #2f6bff;
  --primary-d: #1f53d6;
  --green: #1aa86b;
  --amber: #d98800;
  --danger: #e1483b;
  --king-blue: #0058a3;
  --king-blue-light: #0d7eb9;
  --king-navy: #0f1c4d;
}
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", Segoe UI, Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
.btn {
  background: var(--primary); color: #fff; border: none; border-radius: 8px;
  padding: 8px 16px; font-size: 14px; transition: background .15s;
}
.btn:hover { background: var(--primary-d); }
.btn.ghost { background: #eef2fb; color: var(--primary); }
.btn.ghost:hover { background: #e0e8fb; }
.btn.line { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn.line:hover { background: #f3f5f9; }
input, select {
  font-family: inherit; font-size: 14px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus { outline: none; border-color: var(--primary); }

/* login */
#login-view {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(135deg, var(--king-navy) 0%, #1a3a7a 45%, var(--king-blue-light) 100%);
  overflow: hidden;
}
.login-bg {
  position: absolute; inset: 0; pointer-events: none;
}
.login-bg::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: .6;
}
.login-shape {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: .35; animation: float 10s ease-in-out infinite;
}
.login-shape.shape-1 { width: 380px; height: 380px; background: #3aa6ff; top: -120px; right: -100px; animation-delay: 0s; }
.login-shape.shape-2 { width: 320px; height: 320px; background: #5d7cff; bottom: -90px; left: -80px; animation-delay: -4s; }
.login-shape.shape-3 { width: 220px; height: 220px; background: #00c6e0; top: 45%; left: 55%; opacity: .22; animation-delay: -7s; }
@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-18px) scale(1.05); }
}

.login-card {
  position: relative; z-index: 2;
  background: rgba(255,255,255,.96); border: 1px solid rgba(255,255,255,.45);
  border-radius: 24px; padding: 42px 40px 36px; width: 420px; max-width: 92vw;
  box-shadow: 0 28px 80px rgba(0,18,50,.28);
  backdrop-filter: blur(16px);
  animation: cardIn .55s cubic-bezier(.22,.61,.36,1) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(28px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card .brand {
  display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 26px;
}
.brand-logo {
  width: 48px; height: 48px; border-radius: 14px;
  background: linear-gradient(135deg, var(--king-blue) 0%, var(--king-blue-light) 100%);
  color: #fff; font-size: 24px; font-weight: 800; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(0,88,163,.28);
}
.brand-text { text-align: left; }
.brand-cn { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: .5px; }
.brand-en { font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; margin-top: 2px; }

.login-card h1 { font-size: 22px; text-align: center; margin-bottom: 4px; color: var(--text); }
.login-card .sub { color: var(--king-blue); text-align: center; margin-bottom: 28px; font-size: 13.5px; font-weight: 500; }
.login-card .field { margin-bottom: 18px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 500; }
.login-card .input-wrap { position: relative; }
.login-card .input-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 15px; opacity: .55; pointer-events: none;
}
.login-card input {
  width: 100%; padding: 12px 14px 12px 42px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; font-size: 14px;
  transition: border-color .2s, box-shadow .2s;
}
.login-card input:focus { outline: none; border-color: var(--king-blue); box-shadow: 0 0 0 4px rgba(0,88,163,.1); }
.login-card .err {
  color: var(--danger); font-size: 13px; min-height: 18px; margin: -6px 0 12px;
  font-weight: 500; animation: none;
}
.login-card .err.show { animation: shake .35s ease-in-out; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.login-card .btn-login {
  width: 100%; padding: 13px; font-size: 15px; font-weight: 600; border-radius: 12px;
  background: linear-gradient(135deg, var(--king-blue) 0%, var(--king-blue-light) 100%);
  box-shadow: 0 10px 24px rgba(0,88,163,.28);
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.login-card .btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(0,88,163,.34);
  filter: brightness(1.05);
}
.login-card .btn-login:active { transform: translateY(1px); }
.login-card .btn-login.loading { pointer-events: none; opacity: .8; }

.login-card .login-tip {
  color: var(--muted); font-size: 12px; text-align: center; margin-top: 20px; line-height: 1.7;
}
.login-card .login-tip .code { font-size: 11.5px; background: #eef1f6; padding: 2px 6px; border-radius: 4px; }

@media (max-width: 480px) {
  .login-card { padding: 32px 24px 28px; border-radius: 20px; }
  .login-card h1 { font-size: 20px; }
}

/* layout */
#main-view { display: none; max-width: 1100px; margin: 0 auto; padding: 22px 18px 60px; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.topbar h1 { font-size: 19px; flex: 1; }
.topbar .who { color: var(--muted); font-size: 13px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px;
}
.card h2 { font-size: 15px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.stats { display: flex; gap: 14px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 140px; background: #fafbfe; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat.total .n { color: var(--primary); }
.stat.signed .n { color: var(--green); }
.stat.pending .n { color: var(--amber); }
.stat.overdue .n { color: var(--danger); }

/* nav tabs */
.navtabs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.navtab { background: #fff; border: none; padding: 7px 16px; color: var(--text); border-right: 1px solid var(--line); font-size: 14px; }
.navtab:last-child { border-right: none; }
.navtab.active { background: var(--primary); color: #fff; }

/* mail panel */
.statusbox { font-size: 13px; background: #fafbfe; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; line-height: 1.7; }
.statusbox .ok { color: var(--green); font-weight: 600; }
.statusbox .warn { color: var(--amber); font-weight: 600; }
.statusbox code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.splist { margin-top: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.sprow { display: flex; align-items: center; gap: 10px; background: #fafbfe; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.sprow label { min-width: 92px; font-weight: 600; font-size: 13px; }
.sprow input { flex: 1; }
.ovtable { margin-top: 10px; overflow-x: auto; }
.ovtable table { font-size: 13px; }
.row-overdue { background: #fff6f4; }
.code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.toolbar .seg button { background: #fff; border: none; padding: 7px 14px; color: var(--text); border-right: 1px solid var(--line); }
.toolbar .seg button:last-child { border-right: none; }
.toolbar .seg button.active { background: var(--primary); color: #fff; }
.toolbar input[type=search] { flex: 1; min-width: 180px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; background: #fafbfe; }
td .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; }
.badge.pending { background: #fff4e0; color: var(--amber); }
.badge.signed { background: #e3f7ee; color: var(--green); }
.linkbtn { color: var(--primary); background: none; border: none; padding: 0; font-size: 13px; }
.sigthumb { height: 34px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

/* 审计日志 */
.auditlist { margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.auditrow { display: grid; grid-template-columns: 170px 120px 1fr 140px; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; align-items: baseline; }
.auditrow:nth-child(even) { background: #fafbfe; }
.auditrow:last-child { border-bottom: none; }
.auditrow .at { color: var(--muted); font-variant-numeric: tabular-nums; }
.auditrow .ac { font-weight: 600; color: var(--primary); }
.auditrow .ad { color: var(--text); word-break: break-all; }
.auditrow .aip { color: var(--muted); font-size: 12px; text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.tip { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
#toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: #1f2733; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 99;
}
#toast.show { opacity: .95; }
