/* ============================================================
   仁泰 HR · 统一组件库（单一真相源，配套 tokens.css）
   所有系统统一引用本文件；业务代码里禁止再写按钮/表格/导航的私有样式。
   变量名与 tokens.css 完全一致（无 rt- 前缀）。
   作用域：仅 .rt-* 类，不做全局 reset，避免污染各系统原有布局。
   ============================================================ */

/* ---------- 按钮（全系统 4 态一致） ---------- */
.rt-btn {
  font: 600 var(--fs-md)/1 var(--font);
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}
.rt-btn:disabled { opacity: .55; cursor: not-allowed; }
.rt-btn-primary   { background: var(--brand); color: #fff; }
.rt-btn-primary:hover:not(:disabled)   { background: var(--brand-strong); }
.rt-btn-secondary { background: #fff; color: var(--brand); border-color: var(--border-strong); }
.rt-btn-secondary:hover:not(:disabled) { background: var(--brand-soft); }
.rt-btn-danger    { background: var(--danger); color: #fff; }
.rt-btn-danger:hover:not(:disabled)    { filter: brightness(.94); }
.rt-btn-ghost     { background: transparent; color: var(--text-2); }
.rt-btn-ghost:hover:not(:disabled)     { background: var(--bg-2); }
.rt-btn-sm { padding: 6px 12px; font-size: var(--fs-sm); }
.rt-btn-lg { padding: 11px 22px; font-size: var(--fs-lg); }
.rt-btn-block { width: 100%; }
.rt-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- 顶部导航（一个体系的第一印象） ---------- */
.rt-topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-5);
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  gap: var(--sp-4);
}
.rt-topbar .rt-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; }
.rt-logo-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 15px; flex: none;
}
.rt-topbar .rt-sysname { font-size: var(--fs-lg); font-weight: 600; color: var(--text); }
.rt-topbar .rt-spacer { flex: 1; }
.rt-topbar .rt-user { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: var(--fs-sm); }
.rt-bell {
  position: relative; width: 36px; height: 36px; border-radius: var(--r-pill);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2); cursor: pointer; transition: background 180ms ease;
}
.rt-bell:hover { background: var(--bg-2); }
.rt-bell .rt-dot {
  position: absolute; top: 6px; right: 7px; width: 8px; height: 8px;
  background: var(--danger); border-radius: 50%; border: 2px solid var(--surface);
}

/* ---------- 侧边栏（后台系统统一骨架） ---------- */
.rt-sidebar {
  width: 220px; flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: 100vh;
  padding: var(--sp-4) var(--sp-3);
  box-sizing: border-box;
}
.rt-nav-group { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: var(--sp-4) var(--sp-2) var(--sp-2); }
.rt-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: var(--fs-md); text-decoration: none;
  border-left: 3px solid transparent; cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}
.rt-nav-item svg { width: 18px; height: 18px; flex: none; }
.rt-nav-item:hover { background: var(--bg-2); color: var(--text); }
.rt-nav-item.active { background: var(--brand-soft); color: var(--brand); border-left-color: var(--brand); font-weight: 600; }

/* ---------- 主体布局 ---------- */
.rt-layout { display: flex; min-height: 100vh; background: var(--bg); }
.rt-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rt-content { padding: var(--sp-5); flex: 1; }
.rt-page-title { font-size: var(--fs-2xl); font-weight: 700; color: var(--text); margin: 0 0 var(--sp-2); }
.rt-page-sub { color: var(--text-2); font-size: var(--fs-sm); margin: 0 0 var(--sp-5); }

/* ---------- 卡片 ---------- */
.rt-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-1); padding: var(--sp-5);
  transition: box-shadow 180ms ease;
}
.rt-card:hover { box-shadow: var(--shadow-2); }
.rt-card-title { font-size: var(--fs-lg); font-weight: 600; color: var(--text); margin: 0 0 var(--sp-3); }

/* ---------- 表格（数据系统核心） ---------- */
.rt-table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); background: var(--surface); }
.rt-table th {
  background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: var(--fs-sm);
  text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; white-space: nowrap;
}
.rt-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.rt-table tbody tr:hover { background: var(--surface-2); }
.rt-table tbody tr.selected { background: var(--brand-soft); }
.rt-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); overflow: auto; box-shadow: var(--shadow-1); }

/* ---------- 状态徽标（圆角 pill，语义色浅底深字） ---------- */
.rt-badge {
  display: inline-flex; align-items: center; padding: 2px 10px;
  border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; line-height: 1.7;
  white-space: nowrap;
}
.rt-badge-ok     { background: rgba(21,163,74,.12);  color: var(--ok); }
.rt-badge-warn   { background: rgba(194,130,11,.14); color: var(--warn); }
.rt-badge-danger { background: rgba(208,52,44,.12);  color: var(--danger); }
.rt-badge-info   { background: var(--brand-soft);    color: var(--brand); }

/* ---------- 输入框 / 选择 / 文本域 ---------- */
.rt-input, .rt-select, .rt-textarea {
  font: var(--fs-md)/1.5 var(--font);
  padding: 9px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: #fff; color: var(--text); width: 100%;
  box-sizing: border-box;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.rt-textarea { resize: vertical; min-height: 84px; }
.rt-input:focus, .rt-select:focus, .rt-textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.rt-field { margin-bottom: var(--sp-4); }
.rt-field > label { display: block; font-size: var(--fs-sm); color: var(--text-2); margin-bottom: 6px; font-weight: 600; }

/* ---------- 弹窗 ---------- */
.rt-modal-mask {
  position: fixed; inset: 0; background: rgba(16,24,40,.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: var(--z-modal); padding: var(--sp-4);
}
.rt-modal {
  background: var(--surface); border-radius: var(--r-lg); width: 520px; max-width: 92vw;
  padding: var(--sp-5); box-shadow: var(--shadow-2);
}
.rt-modal-title { font-size: var(--fs-xl); font-weight: 700; color: var(--text); margin: 0 0 var(--sp-4); }
.rt-modal-actions { display: flex; justify-content: flex-end; gap: var(--sp-3); margin-top: var(--sp-5); }

/* ---------- 空 / 加载 / 错误 态（三态每系统一致） ---------- */
.rt-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: var(--sp-7) var(--sp-5); text-align: center; color: var(--muted);
}
.rt-state .rt-state-icon { width: 44px; height: 44px; color: var(--border-strong); }
.rt-state .rt-state-text { font-size: var(--fs-md); }
.rt-state-error { color: var(--danger); }
.rt-state-error .rt-state-icon { color: var(--danger); }
.rt-spinner {
  width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--brand);
  border-radius: 50%; animation: rt-spin .8s linear infinite;
}
@keyframes rt-spin { to { transform: rotate(360deg); } }

/* ---------- 通用工具 ---------- */
.rt-row { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.rt-row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.rt-muted { color: var(--muted); }
.rt-text-2 { color: var(--text-2); }
.rt-mt-3 { margin-top: var(--sp-3); } .rt-mt-4 { margin-top: var(--sp-4); } .rt-mt-5 { margin-top: var(--sp-5); }
.rt-mb-3 { margin-bottom: var(--sp-3); } .rt-mb-4 { margin-bottom: var(--sp-4); } .rt-mb-5 { margin-bottom: var(--sp-5); }

/* ---------- 动效克制：尊重用户偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- 图标（统一 sprite，随文字色变化） ---------- */
.rt-ico {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- 响应式（设计系统主骨架；非 .rt-* 布局不受影响） ---------- */
@media (max-width: 1024px) {
  .rt-sidebar { width: 200px; }
}
@media (max-width: 768px) {
  .rt-layout { flex-direction: column; }
  .rt-sidebar { width: 100%; min-height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .rt-content { padding: var(--sp-4); }
  .rt-table-wrap { overflow-x: auto; }
}
@media (max-width: 480px) {
  .rt-page-title { font-size: var(--fs-xl); }
  .rt-content { padding: var(--sp-3); }
  .rt-topbar { padding: 0 var(--sp-4); }
}

/* ---------- 图标容器尺寸（各系统复用，确保 sprite 正确渲染） ---------- */
.hamburger .rt-ico,
.nav-icon .rt-ico,
.btn-icon .rt-ico,
.sidebar .rt-ico,
.topbar .rt-ico { width: 18px; height: 18px; }
.hamburger .rt-ico { width: 22px; height: 22px; }
