:root {
  /* Apple 风格设计 token */
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --danger: #de3b30;
  --danger-bg: #fff2f0;
  --ok: #1d7a43;
  --ok-bg: #edf9f1;
  --fill: #e8e8ed;
  --fill-hover: #ebebf0;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; color: var(--text-secondary); }
.dim { color: var(--text-secondary); }
.small { font-size: 12px; }

/* ================= 顶栏（Apple 毛玻璃） ================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 22px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand {
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-icon { font-size: 17px; }
.nav { display: flex; gap: 2px; flex: 1; }
.nav-link {
  color: var(--text-secondary);
  padding: 6px 13px;
  border-radius: 8px;
  font-size: 13px;
  transition: color 0.15s;
}
.nav-link:hover { background: transparent; color: var(--text); text-decoration: none; }
.nav-link.active { color: var(--text); font-weight: 600; }
.userbox { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.uname { font-size: 13px; color: var(--text); }
.role-tag { font-size: 11px; padding: 2px 9px; border-radius: 999px; font-weight: 600; }
.tag-admin { background: #1d1d1f; color: #fff; }
.tag-client { background: var(--fill); color: var(--text); }
.logout { color: var(--text-secondary); font-size: 13px; }
.logout:hover { color: var(--text); }

/* ================= 容器与页面头 ================= */
.container { max-width: 1120px; margin: 0 auto; padding: 36px 22px 80px; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin: 4px 0 28px;
  flex-wrap: wrap;
}
.page-head h2 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.page-head .sub { margin: 6px 0 0; color: var(--text-secondary); font-size: 15px; }
.head-actions { display: flex; gap: 10px; }

/* ================= 统计卡片 ================= */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; margin-bottom: 28px; }
.stat-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  color: var(--text);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.stat-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-num { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.stat-label { color: var(--text-secondary); font-size: 13px; margin-top: 6px; }

/* ================= 面板 / 卡片 ================= */
.panel {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}
.panel-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.panel-head h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.form-panel { padding: 26px 28px; }
.link { font-size: 13px; }

/* ================= 表格 ================= */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 13px 24px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-secondary); font-weight: 500; font-size: 12px; letter-spacing: 0.02em; background: transparent; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(0, 0, 0, 0.02); }
.ctitle { font-weight: 600; color: var(--text); }
.clients-cell { max-width: 260px; }
.empty { text-align: center; color: var(--text-secondary); padding: 28px; }
.ops { white-space: nowrap; }
.ops .btn { margin-right: 6px; }

/* ================= 徽章 ================= */
.pill { display: inline-block; background: var(--fill); color: var(--text); font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 500; }
.pill-green { background: var(--ok-bg); color: var(--ok); }
.action-tag { display: inline-block; background: var(--fill); color: var(--text); font-size: 12px; padding: 3px 9px; border-radius: 7px; }
.actor { font-weight: 600; }

/* ================= 按钮（Apple 胶囊风格） ================= */
.btn {
  display: inline-block;
  border: none;
  background: var(--fill);
  color: var(--text);
  padding: 8px 18px;
  border-radius: 980px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.4;
  text-align: center;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--fill-hover); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #fde4e1; }
.btn-sm { padding: 5px 13px; font-size: 13px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ================= 表单 ================= */
.form { display: flex; flex-direction: column; gap: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--text); }
.field input[type="text"], .field input[type="password"], .field textarea, .field input:not([type]) {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: 15px;
  font-family: inherit;
  width: 100%;
  background: var(--bg-elevated);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18);
}
.field input[type="file"] {
  font-size: 13px;
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text-secondary);
}
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin-top: 4px; }
.check {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.check:hover { border-color: var(--border-strong); }
.check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.assign-form { padding: 20px 24px; }

/* ================= 提示横幅 ================= */
.banner { padding: 13px 18px; border-radius: var(--radius-md); margin-bottom: 20px; font-size: 14px; }
.banner-ok { background: var(--ok-bg); color: var(--ok); }
.banner-err { background: var(--danger-bg); color: var(--danger); }

/* ================= 合同卡片（客户视角） ================= */
.contract-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.contract-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.contract-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.contract-card h3 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.cc-head { display: flex; justify-content: space-between; align-items: center; }
.cc-desc { margin: 0; color: var(--text-secondary); font-size: 13px; }
.cc-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.empty-state {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 60px 20px;
  text-align: center;
  color: var(--text-secondary);
}
.empty-state p { margin: 4px 0; }

/* ================= 描述框 ================= */
.desc-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 24px;
  color: var(--text);
}

/* ============================================================
   登录页（Apple 高级感 + 动画角色）
   ============================================================ */
.login-scene {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}
.login-left {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--bg);
  padding: 44px 48px;
  overflow: hidden;
}
.login-left::before,
.login-left::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
}
.login-left::before {
  bottom: 12%;
  left: 8%;
  width: 340px;
  height: 340px;
  background: rgba(190, 180, 220, 0.28);
}
.login-left::after {
  top: 16%;
  right: 12%;
  width: 260px;
  height: 260px;
  background: rgba(240, 210, 150, 0.25);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  position: relative;
  z-index: 2;
  letter-spacing: -0.01em;
}
.login-brand .brand-icon { font-size: 22px; }
.login-tagline {
  position: relative;
  z-index: 2;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  gap: 22px;
}

/* ---- 动画角色场景 ---- */
.characters-wrapper {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex: 1;
  min-height: 360px;
}
.characters-scene { position: relative; width: 480px; height: 360px; }
.character {
  position: absolute;
  bottom: 0;
  transition: all 0.7s ease-in-out;
  transform-origin: bottom center;
}
.char-a { left: 60px; width: 170px; height: 370px; background: #8a7fd0; border-radius: 10px 10px 0 0; z-index: 1; }
.char-b { left: 220px; width: 115px; height: 290px; background: #3a3a3e; border-radius: 8px 8px 0 0; z-index: 2; }
.char-c { left: 0; width: 230px; height: 190px; background: #f0ab82; border-radius: 115px 115px 0 0; z-index: 3; }
.char-d { left: 290px; width: 135px; height: 215px; background: #e6d48f; border-radius: 68px 68px 0 0; z-index: 4; }

.eyes { position: absolute; display: flex; transition: all 0.7s ease-in-out; }
.eyeball {
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: height 0.15s ease;
  overflow: hidden;
}
.pupil { border-radius: 50%; background: #2d2d2d; transition: transform 0.1s ease-out; }
.bare-pupil { width: 12px; height: 12px; border-radius: 50%; background: #2d2d2d; transition: transform 0.7s ease-in-out; }
.mouth { position: absolute; width: 50px; height: 4px; background: #2d2d2d; border-radius: 2px; transition: all 0.7s ease-in-out; }
.sad-mouth {
  position: absolute;
  width: 28px;
  height: 14px;
  border: 3px solid #2d2d2d;
  border-top: none;
  border-radius: 0 0 14px 14px;
  opacity: 0;
  transition: all 0.7s ease-in-out;
}
.sad-mouth.visible { opacity: 1; }

@keyframes shakeHead {
  0%, 100% { translate: 0 0; }
  10% { translate: -9px 0; }
  20% { translate: 7px 0; }
  30% { translate: -6px 0; }
  40% { translate: 5px 0; }
  50% { translate: -4px 0; }
  60% { translate: 3px 0; }
  70% { translate: -2px 0; }
  80% { translate: 1px 0; }
  90% { translate: -0.5px 0; }
}
.shake-head { animation: shakeHead 0.8s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }

/* ---- 右侧表单 ---- */
.login-right {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  padding: 48px;
}
.login-form-wrap { width: 100%; max-width: 380px; }
.login-form-wrap h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 6px;
}
.login-form-wrap .sub { color: var(--text-secondary); font-size: 15px; margin: 0 0 36px; }

.login-group { margin-bottom: 20px; }
.login-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 8px; }
.login-group .input-wrapper { position: relative; }
.login-group input {
  width: 100%;
  height: 48px;
  border: none;
  border-bottom: 1px solid var(--border-strong);
  padding: 0 40px 0 0;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: transparent;
  outline: none;
  transition: border-color 0.25s;
}
.login-group input:focus { border-bottom-color: var(--accent); }
.login-group input::placeholder { color: var(--text-tertiary); }
.login-group input[type="password"]:not(:placeholder-shown) { letter-spacing: 2px; }
.login-group input[type="password"]::-ms-reveal,
.login-group input[type="password"]::-ms-clear { display: none; }
.login-group input.error { border-bottom-color: var(--danger); }
.login-group label.error-label { color: var(--danger); }

.toggle-password {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 6px;
  transition: color 0.2s;
}
.toggle-password:hover { color: var(--text); }

.login-err { min-height: 0; }
.login-err .banner { margin: 4px 0 16px; }

.btn-login {
  position: relative;
  width: 100%;
  height: 50px;
  border-radius: 980px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: background 0.3s;
}
.btn-login .btn-text { display: inline-block; transition: all 0.3s; }
.btn-login .btn-hover-content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-hover);
  color: #fff;
  opacity: 0;
  transition: all 0.3s;
  border-radius: 980px;
}
.btn-login:hover .btn-text { transform: translateX(40px); opacity: 0; }
.btn-login:hover .btn-hover-content { opacity: 1; }
.btn-login:disabled { opacity: 0.7; cursor: not-allowed; }

.login-hint { text-align: center; color: var(--text-tertiary); font-size: 12px; margin: 26px 0 0; }

/* 响应式 */
@media (max-width: 900px) {
  .login-scene { grid-template-columns: 1fr; }
  .login-left { display: none; }
}

/* ================= 筛选栏 ================= */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.filter-search {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 400px;
}
.filter-search svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}
.filter-search input {
  width: 100%;
  height: 40px;
  border: none;
  background: var(--bg-elevated);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  padding: 0 14px 0 38px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
}
.filter-search input:focus { box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18); }
.filter-search input::placeholder { color: var(--text-tertiary); }
.filter-bar select {
  height: 40px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  padding: 0 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  outline: none;
}
.filter-bar select:focus { box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18); }
.filter-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 32px;
  font-size: 14px;
}

/* ================= 客户合同详情 ================= */
.back-link {
  display: inline-block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.back-link:hover { color: var(--accent); text-decoration: none; }
.panel-body { padding: 20px 24px; }
.detail-desc { line-height: 1.85; color: var(--text); font-size: 15px; }
.cc-title { color: var(--text); font-weight: 600; }
.cc-title:hover { color: var(--accent); text-decoration: none; }
