/* ============================================================
 * 新员工入职智能填报台 —— 样式
 * ========================================================== */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #1e293b;
  --muted: #64748b;
  --brand: #1d4ed8;
  --brand-soft: #eff6ff;
  --error: #dc2626;
  --error-soft: #fef2f2;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --ok: #047857;
  --ok-soft: #ecfdf5;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 60px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.topbar .logo {
  width: 30px; height: 30px; border-radius: 7px;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; letter-spacing: .3px; }
.topbar .sub { font-size: 12px; color: var(--muted); margin-left: 2px; }
.topbar .spacer { flex: 1; }

.status {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; background: transparent;
  transition: background .15s;
}
.status:hover { background: var(--bg); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.status.ok { color: var(--ok); background: var(--ok-soft); border-color: #a7f3d0; }
.status.ok .dot { background: var(--ok); }
.status.warn { color: var(--warn); background: var(--warn-soft); border-color: #fde68a; }
.status.warn .dot { background: var(--warn); }
.status.error { color: var(--error); background: var(--error-soft); border-color: #fecaca; }
.status.error .dot { background: var(--error); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--text);
  font-size: 13px; font-family: inherit; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500;
}
.btn.primary:hover { background: #1e40af; border-color: #1e40af; color: #fff; }
.btn.accent { background: #0f766e; border-color: #0f766e; color: #fff; font-weight: 500; }
.btn.accent:hover { background: #115e59; border-color: #115e59; color: #fff; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg); color: var(--brand); border-color: transparent; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line-strong); color: var(--text); background: var(--panel); }

/* ---------------- 布局 ---------------- */
.layout { display: flex; align-items: flex-start; gap: 0; }

.sidebar {
  position: sticky; top: 60px;
  width: 224px; flex: 0 0 224px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 14px 10px 40px;
}
.side-group { font-size: 11px; color: var(--muted); padding: 12px 10px 6px; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 6px;
  color: var(--text); text-decoration: none; font-size: 13.5px;
  cursor: pointer; transition: background .12s;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.nav-item .idx {
  width: 20px; height: 20px; border-radius: 5px; flex: 0 0 auto;
  background: var(--bg); color: var(--muted);
  font-size: 11px; display: flex; align-items: center; justify-content: center;
}
.nav-item.active .idx { background: var(--brand); color: #fff; }
.nav-item .badge {
  margin-left: auto; min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; font-size: 10.5px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.nav-item .badge.e { background: var(--error); }
.nav-item .badge.w { background: var(--warn); }

.main { flex: 1; min-width: 0; padding: 22px 28px 120px; max-width: 1180px; }

/* ---------------- 卡片 / 区块 ---------------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 18px;
  box-shadow: var(--shadow); overflow: hidden;
  scroll-margin-top: 78px;
}
.card > h2 {
  margin: 0; padding: 14px 20px;
  font-size: 14.5px; font-weight: 600;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.card > h2 .n {
  width: 21px; height: 21px; border-radius: 5px;
  background: var(--brand-soft); color: var(--brand);
  font-size: 11.5px; display: flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.card > h2 .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.card .body { padding: 18px 20px; }
.card .body.tight { padding: 0; }

/* ---------------- 表单网格 ---------------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.span2 { grid-column: 1 / -1; }
.field > label {
  font-size: 12.5px; color: var(--muted); font-weight: 500;
  display: flex; align-items: center; gap: 4px;
}
.field > label .req { color: var(--error); font-weight: 700; }
.field > label .tag {
  font-size: 10.5px; padding: 0 5px; border-radius: 3px;
  background: #eef2f7; color: var(--muted); font-weight: 400;
}

input, select, textarea {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--line-strong); border-radius: 6px;
  font-size: 13.5px; font-family: inherit; color: var(--text);
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .1);
}
input[readonly] { background: #f8fafc; color: var(--muted); cursor: default; }
textarea { resize: vertical; min-height: 56px; }
select { cursor: pointer; }
input[type="date"] { cursor: text; }

.field.err input, .field.err select, .field.err textarea {
  border-color: var(--error); background: var(--error-soft);
}
.field.wr input, .field.wr select, .field.wr textarea {
  border-color: var(--warn); background: var(--warn-soft);
}
.msg { font-size: 11.5px; display: none; }
.field.err .msg { display: block; color: var(--error); }
.field.wr .msg { display: block; color: var(--warn); }
.tip { font-size: 11.5px; color: var(--muted); }

/* ---------------- 明细表 ---------------- */
.table-wrap { overflow-x: auto; }
table.rp { width: 100%; border-collapse: collapse; font-size: 13px; }
table.rp th {
  background: #f8fafc; border-bottom: 1px solid var(--line);
  padding: 9px 8px; text-align: left; font-weight: 500;
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
table.rp th .req { color: var(--error); }
table.rp td {
  border-bottom: 1px solid var(--line); padding: 6px 8px; vertical-align: top;
}
table.rp td input, table.rp td select { padding: 5px 7px; font-size: 12.5px; }
table.rp tr:hover td { background: #fafcff; }
table.rp .op { width: 46px; text-align: center; white-space: nowrap; }
table.rp .op button {
  border: none; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 15px; padding: 2px 5px; border-radius: 4px;
}
table.rp .op button:hover { color: var(--error); background: var(--error-soft); }
table.rp .sn { width: 34px; text-align: center; color: var(--muted); font-size: 12px; }
table.rp .cell-err input, table.rp .cell-err select {
  border-color: var(--error); background: var(--error-soft);
}

.empty { padding: 26px; text-align: center; color: var(--muted); font-size: 13px; }
.row-actions { padding: 12px 20px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-actions .count { font-size: 12.5px; color: var(--muted); margin-left: auto; }

/* 标记列（最高学历 / 第一学历） */
.flags { display: flex; flex-direction: column; gap: 2px; }
.flags label {
  display: flex; align-items: center; gap: 4px;
  font-size: 11.5px; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.flags input { width: auto; margin: 0; cursor: pointer; }

/* ---------------- 校验结果抽屉 ---------------- */
.drawer {
  position: fixed; right: 0; top: 60px; bottom: 0; width: 430px;
  background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -4px 0 16px rgba(15, 23, 42, .08);
  transform: translateX(100%); transition: transform .22s ease;
  z-index: 60; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer header {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.drawer header h3 { margin: 0; font-size: 14px; font-weight: 600; flex: 1; }
.drawer .content { flex: 1; overflow-y: auto; padding: 12px 14px 30px; }
.drawer .empty-box { text-align: center; padding: 50px 20px; color: var(--muted); }

.issue {
  display: flex; gap: 9px; padding: 9px 11px; margin-bottom: 7px;
  border-radius: 6px; font-size: 12.5px; cursor: pointer;
  border: 1px solid transparent;
}
.issue:hover { filter: brightness(.98); }
.issue.error { background: var(--error-soft); border-color: #fecaca; }
.issue.warn { background: var(--warn-soft); border-color: #fde68a; }
.issue .ic { flex: 0 0 auto; font-style: normal; font-weight: 700; }
.issue.error .ic { color: var(--error); }
.issue.warn .ic { color: var(--warn); }
.issue .txt { flex: 1; min-width: 0; }
.issue .path { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }

.mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .3);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 55;
}
.mask.show { opacity: 1; pointer-events: auto; }

/* ---------------- 导出面板 ---------------- */
.export-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 12px; }
.file-card {
  border: 1px solid var(--line); border-radius: 7px; padding: 13px 15px;
  display: flex; align-items: center; gap: 12px; background: #fff;
}
.file-card .fi {
  width: 34px; height: 34px; border-radius: 6px; flex: 0 0 auto;
  background: var(--ok-soft); color: var(--ok);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.file-card .fi.off { background: #f1f5f9; color: var(--muted); }
.file-card .meta { flex: 1; min-width: 0; }
.file-card .nm { font-size: 13.5px; font-weight: 500; }
.file-card .ds { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.file-card input[type="checkbox"] { width: 17px; height: 17px; cursor: pointer; flex: 0 0 auto; }

.opt-row {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px;
}
.opt-row:last-child { border-bottom: none; }
.opt-row input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.opt-row .d { font-size: 11.5px; color: var(--muted); }

/* ---------------- 字典维护 ---------------- */
.dict-edit { padding: 10px 0; border-bottom: 1px solid var(--line); }
.dict-edit:last-child { border-bottom: none; }
.dict-edit .nm { font-size: 13px; font-weight: 500; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.dict-edit .nm .badge {
  font-size: 10px; padding: 1px 6px; border-radius: 3px;
  background: var(--warn-soft); color: var(--warn); border: 1px solid #fde68a;
}
.dict-edit textarea { font-size: 12.5px; min-height: 62px; font-family: inherit; }
.dict-edit .ops { margin-top: 7px; display: flex; gap: 8px; }

/* ---------------- 提示条 ---------------- */
.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 15px; border-radius: 7px; margin-bottom: 16px; font-size: 13px;
}
.banner.info { background: var(--brand-soft); border: 1px solid #bfdbfe; color: #1e40af; }
.banner.warn { background: var(--warn-soft); border: 1px solid #fde68a; color: #92400e; }
.banner .ic { flex: 0 0 auto; font-style: normal; font-weight: 700; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(20px);
  background: #1e293b; color: #fff; padding: 10px 20px; border-radius: 7px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 200;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 链接有效期提醒 ---------------- */
.link-expiry {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 10px 14px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 13px; line-height: 1.6;
  background: var(--panel); color: var(--text);
  box-shadow: var(--shadow);
}
.link-expiry .le-icon { flex: none; font-weight: 700; width: 18px; text-align: center; }
.link-expiry .le-body { flex: 1; }
.link-expiry .le-body b { font-weight: 600; }
.link-expiry.le-ok    { border-color: var(--ok-soft);    background: var(--ok-soft);    color: var(--ok); }
.link-expiry.le-warn  { border-color: #fde68a;           background: var(--warn-soft); color: var(--warn); }
.link-expiry.le-expired { border-color: #fecaca;         background: var(--error-soft); color: var(--error); }

/* ---------------- 移动端适配（≤900px 平板/手机） ---------------- */
@media (max-width: 900px) {
  .layout { flex-direction: column; align-items: stretch; }

  /* 侧栏改成顶部横向滚动导航，常驻可见，点哪跳哪 */
  .sidebar {
    position: sticky; top: 60px; z-index: 40;
    width: 100%; flex: 0 0 auto;
    height: auto; max-height: 46px;
    border-right: none; border-bottom: 1px solid var(--line);
    padding: 6px 10px;
    display: flex; flex-direction: row; flex-wrap: nowrap; gap: 6px;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .side-group { display: none; }
  .nav-item {
    display: inline-flex; flex: 0 0 auto;
    padding: 5px 10px; min-width: max-content;
    font-size: 12.5px; white-space: nowrap;
  }
  .nav-item .idx { width: 18px; height: 18px; font-size: 10.5px; flex: 0 0 auto; }

  /* 卡片定位偏移要把侧栏算进去 */
  .card { scroll-margin-top: 112px; }

  /* 主区与卡片紧凑 */
  .main { padding: 14px 14px 100px; }
  .card > h2 { padding: 11px 14px; font-size: 13.5px; }
  .card > h2 .hint { display: none; }
  .card .body { padding: 13px 14px; }
  .row-actions { padding: 10px 14px; gap: 8px; }

  /* 校验抽屉：全屏 */
  .drawer { width: 100%; }

  /* 顶栏紧凑 */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .sub { display: none; }

  /* 中文标签不断词 */
  .field > label { word-break: keep-all; }
}

/* 小屏手机（≤640px） */
@media (max-width: 640px) {
  html, body { font-size: 14px; }
  .topbar { padding: 0 10px; gap: 6px; }
  .topbar h1 { font-size: 13px; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .status { padding: 3px 8px; font-size: 11px; }
  .topbar .btn { padding: 4px 9px; font-size: 11.5px; }
  .topbar .btn.sm { padding: 3px 7px; font-size: 10.5px; }
  .grid { gap: 12px; }
  /* iOS focus 时 font-size<16 会自动放大，保持 14px+ 避免抖动 */
  input, select, textarea { font-size: 14px; padding: 9px 11px; }
  .export-grid { grid-template-columns: 1fr; }
  .opt-row { flex-wrap: wrap; }
}

/* ---------------- 打印 ---------------- */
@media print {
  .topbar, .sidebar, .drawer, .mask, .toast, .card > h2 .hint, .btn { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; max-width: none; }
  .card { border: none; box-shadow: none; margin: 0; break-inside: avoid; }
}
