/* =============================================================================
 * 绩效考核助手 · 设计系统（阶段5.2 UI 升级）
 * 无构建、无第三方依赖，纯手写。移动端 + PC 自适应。
 * -----------------------------------------------------------------------------
 * 结构：
 *   1) Design Tokens（颜色/圆角/阴影/间距，全站唯一来源，页面样式引用变量）
 *   2) 全局基础（reset/字体/背景/滚动条）
 *   3) 共享组件（卡片/按钮/表单/徽标/表格/顶栏/提示条/空态）
 *   4) 登录页&身份页专属（.card 居中布局，向后兼容旧 class）
 * 兼容性约定：旧页面用到的所有 class 名一律保留，只改视觉。
 * ========================================================================== */

/* ---- 1) Design Tokens ---- */
:root {
  /* 品牌绿（企业微信系，加深提高对比度） */
  --brand: #0a9e5c;
  --brand-strong: #087a47;
  --brand-soft: #e7f6ef;
  --brand-border: #bfe8d4;

  /* 中性色 */
  --ink: #182026;            /* 主文字 */
  --ink-2: #4b5563;          /* 次级文字 */
  --muted: #8a94a6;          /* 弱文字 */
  --line: #e6e9ef;           /* 分隔线/描边 */
  --bg: #f2f4f8;             /* 页面底 */
  --card: #ffffff;

  /* 语义色（soft 背景 + strong 文字，成对使用） */
  --ok-soft: #e7f6ef;    --ok-strong: #0a7a4b;   --ok-border: #bfe8d4;
  --warn-soft: #fdf3e3;  --warn-strong: #9a5b0b; --warn-border: #f5ddb0;
  --danger-soft: #fdecec;--danger-strong: #c0392b;--danger-border: #f5c6c3;
  --info-soft: #e9effd;  --info-strong: #2f4fb6; --info-border: #c7d5f7;
  --neutral-soft: #eef1f5; --neutral-strong: #4b5563;

  /* 兼容旧变量名（老页面/内联样式仍引用它们） */
  --color-primary: var(--brand);
  --color-primary-dark: var(--brand-strong);
  --color-text: var(--ink);
  --color-text-weak: var(--ink-2);
  --color-bg: var(--bg);
  --color-card: var(--card);
  --color-border: var(--line);
  --color-danger: #e5484d;

  /* 圆角 / 阴影 */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(24, 32, 38, 0.05), 0 1px 6px rgba(24, 32, 38, 0.04);
  --shadow: 0 2px 8px rgba(24, 32, 38, 0.06), 0 8px 24px rgba(24, 32, 38, 0.05);
  --shadow-lg: 0 4px 16px rgba(24, 32, 38, 0.08), 0 16px 40px rgba(24, 32, 38, 0.08);

  --focus-ring: 0 0 0 3px rgba(10, 158, 92, 0.22);
}

/* ---- 2) 全局基础 ---- */
* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink);
  /* 顶部一抹淡淡的品牌色渐变，替代死板纯灰 */
  background:
    radial-gradient(1200px 340px at 50% -80px, rgba(10, 158, 92, 0.09), rgba(10, 158, 92, 0) 70%),
    var(--bg);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* 居中布局（登录/身份页 body 加 .centered；旧页面没有该 class 时由下方兼容段兜底） */
body.centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

::selection { background: rgba(10, 158, 92, 0.18); }

/* ---- 3) 共享组件 ---- */

/* 顶栏：宽页面（我的考核 / HR 管理）通用页头 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand-dot {
  width: 26px; height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), #0bb96d);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(10, 158, 92, 0.35);
}
.topbar-title {
  font-size: 14px;
  color: var(--muted);
  flex: 1 1 auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-nav { display: inline-flex; gap: 4px; }
.topbar-nav a {
  font-size: 13px;
  color: var(--ink-2);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
}
.topbar-nav a:hover { background: var(--neutral-soft); color: var(--ink); }
.topbar-nav a.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }

/* 窄屏（手机）：品牌 + 导航都不换行，中间标题会被挤到近 0 甚至顶破。
   隐藏中间标题给导航让位，顶栏锁定单行不出血（sticky 高度不变，不影响 #global-msg 偏移）。 */
@media (max-width: 480px) {
  .topbar-title { display: none; }
  .topbar-inner { gap: 8px; }
  .topbar-nav a { padding: 6px 8px; }
}

/* 卡片 */
.card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid rgba(230, 233, 239, 0.7);
  padding: 32px 26px;
}

/* 品牌徽（登录/身份卡顶部圆标） */
.brand-mark {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--brand), #0bb96d);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700;
  box-shadow: 0 6px 16px rgba(10, 158, 92, 0.35);
}

/* 标题 */
.title { font-size: 21px; font-weight: 700; margin: 0 0 6px; text-align: center; letter-spacing: 0.2px; }
.subtitle { font-size: 13.5px; color: var(--muted); text-align: center; margin: 0 0 26px; }

/* 按钮 */
.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  color: #fff;
  background: var(--brand);
  transition: background-color .15s ease, transform .06s ease, box-shadow .15s ease;
  box-shadow: 0 1px 2px rgba(8, 122, 71, 0.25);
}
.btn:hover { background: var(--brand-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); }

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line);
  box-shadow: none;
  font-weight: 500;
}
.btn-ghost:hover { background: #f7f8fa; color: var(--ink); }

.btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-weight: 500;
}
.btn-secondary:hover { background: #f7f8fa; }

.btn-danger { background: #e5484d; color: #fff; }
.btn-danger:hover { background: #d93a3f; }

.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; width: auto; display: inline-block; }
.btn-inline { width: auto; display: inline-block; }

.btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }

/* 表单控件（全局基线；页面栅格布局由各页自持） */
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  transition: border-color .12s ease, box-shadow .12s ease;
  /* 移动端防溢出根因修复：控件绝不超过容器宽；grid/flex 子项内可收缩到列宽以下。
     缺此约束时 <select> 会按最长 option、date/number input 会按 UA 默认宽把窄列顶破。 */
  max-width: 100%;
  min-width: 0;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
textarea { resize: vertical; min-height: 56px; }
label { font-size: 13px; color: var(--ink-2); }

/* 栅格表单单元 .field（hr/goals 各表单、评价链、评分行共用）：
   子项可收缩 + 控件铺满单列。与上面的 max-width:100% 合力根治窄屏撑破。 */
.field { min-width: 0; }
.field > input, .field > select, .field > textarea { width: 100%; max-width: 100%; }

/* 徽标基线（各页的 badge-xxx 配色仍在页内定义/或用语义变量） */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 18px;
  white-space: nowrap;
  font-weight: 500;
}

/* 信息行（身份页） */
.info-list { margin: 0 0 22px; padding: 0; list-style: none; }
.info-row {
  display: flex; align-items: baseline;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}
.info-row:last-child { border-bottom: none; }
.info-label { flex: 0 0 84px; color: var(--muted); font-size: 13.5px; }
.info-value { flex: 1; min-width: 0; font-size: 15px; word-break: break-all; }

/* 上级链 chips */
.chain { display: flex; flex-wrap: wrap; gap: 6px 4px; align-items: center; }
.chain-item {
  background: var(--brand-soft);
  color: var(--brand-strong);
  border: 1px solid var(--brand-border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12.5px;
  font-weight: 500;
}
.chain-arrow { color: var(--muted); font-size: 12px; }

/* 横幅提示 */
.banner {
  background: var(--brand-soft);
  color: var(--brand-strong);
  border: 1px solid var(--brand-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  text-align: center;
  margin-bottom: 20px;
  font-weight: 500;
}

/* 状态文本（加载中 / 错误） */
.state { text-align: center; color: var(--muted); font-size: 14px; padding: 14px 0; }
.state-error { color: var(--danger-strong); }

/* 工具类 */
.hidden { display: none !important; }
.mt-12 { margin-top: 12px; }
.muted { color: var(--muted); font-size: 13px; }

/* 页脚 */
.footer { margin-top: 18px; text-align: center; font-size: 12px; color: var(--muted); }

/* ---- 4) 兼容：登录/身份页（body 未加 .centered 的旧标记）----
 * index.html / me.html 的 body 只有一个 .card 直接子元素时仍垂直居中。 */
body:not(.page) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

/* 宽页面（我的考核 / HR 管理）：body 加 .page 取消居中布局 */
body.page {
  display: block;
  padding: 0 0 48px;
}
