/* ===========================================================
   协同工作台 · 工作协作平台
   =========================================================== */

:root {
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-soft: #f8f9fd;
  --text: #1b2033;
  --text-soft: #4a5169;
  --muted: #8a91a8;
  --border: #e6e8f2;
  --border-strong: #d5d9e8;

  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef0ff;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --success: #12a06a;
  --warning: #d98d00;

  /* 出差标识：福州市内 / 福州市外统一使用同一套醒目色 */
  --trip: #ea580c;
  --trip-soft: #fff1e4;
  --trip-border: #fbcfa6;

  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(24, 30, 56, .05), 0 1px 3px rgba(24, 30, 56, .04);
  --shadow-md: 0 6px 22px rgba(24, 30, 56, .08);
  --shadow-lg: 0 22px 60px rgba(24, 30, 56, .18);
}

* { box-sizing: border-box; }

/* 作者样式里的 display 会盖掉浏览器默认的 [hidden] { display: none }，这里统一兜底 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;                 /* 页面整体不滚动，全屏适配 */
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }

button { font-family: inherit; }

/* ---------- 通用控件 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s, color .16s, border-color .16s, box-shadow .16s, transform .1s;
  background: transparent;
  color: var(--text-soft);
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(79, 70, 229, .28); }
.btn-primary:hover { background: var(--primary-dark); }

.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover { background: #e2e5ff; }

.btn-ghost { border-color: var(--border-strong); background: var(--surface); }
.btn-ghost:hover { background: var(--surface-soft); border-color: var(--muted); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #cf3b40; }

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

.btn .plus { font-size: 16px; line-height: 1; margin-top: -1px; }

.icon-btn {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 9px;
  color: var(--text-soft);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background .16s, color .16s, border-color .16s;
}
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

/* 统一表单控件外观
   这里用「排除法」而不是枚举 type：枚举容易漏（例如早期的 password 就被漏掉，
   导致密码框回退成浏览器默认外观），排除 checkbox / radio / file 三类用原生样式的即可。
   :where() 让排除条件不产生额外优先级，保持与原先一致的层叠关系。 */
input:where(:not([type="checkbox"]):not([type="radio"]):not([type="file"])),
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
input:where(:not([type="checkbox"]):not([type="radio"]):not([type="file"])):focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .13);
}
input:where(:not([type="checkbox"]):not([type="radio"]):not([type="file"])):disabled,
select:disabled,
textarea:disabled {
  background: var(--surface-soft);
  color: var(--muted);
  cursor: not-allowed;
}
textarea { resize: vertical; min-height: 62px; }
select { cursor: pointer; }

/* ---------- 顶部 ---------- */

.app-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-logo {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(99, 102, 241, .3);
}

.brand-text h1 { font-size: 16px; font-weight: 700; letter-spacing: .3px; }
.brand-text p { font-size: 11px; color: var(--muted); letter-spacing: .6px; text-transform: uppercase; }

.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- 工具栏 ---------- */

.toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 12px 24px 0;
}

.month-nav { display: flex; align-items: center; gap: 8px; }

.month-label { font-size: 19px; font-weight: 700; margin-left: 6px; letter-spacing: .4px; }

.month-hint { font-size: 12px; color: var(--muted); margin-left: 4px; }

.member-switch { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 13px 5px 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  transition: all .16s;
}
.member-chip:hover { border-color: var(--muted); }
.member-chip.is-active {
  border-color: transparent;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 5px 14px rgba(79, 70, 229, .26);
}
.member-chip.is-dim { opacity: .45; }

.avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  flex: 0 0 auto;
}
.avatar-lg { width: 34px; height: 34px; font-size: 13px; }

.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -7px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- 布局 ---------- */

.layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  gap: 18px;
  align-items: stretch;
  padding: 12px 24px 20px;
  overflow: hidden;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.calendar-card { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.rail { display: flex; flex-direction: column; gap: 18px; min-width: 0; min-height: 0; }

/* ---------- 月历 ---------- */

.weekdays {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
}
.weekdays span {
  padding: 9px 0;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .5px;
}
.weekdays span.is-weekend { color: #b0a4c8; }

.calendar {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);   /* 6 行均分可视高度，内容超出则裁剪 */
  gap: 1px;
  background: var(--border);
}

.day-cell {
  background: var(--surface);
  padding: 6px 6px 7px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  cursor: pointer;
  transition: background .14s;
}
.day-cell:hover { background: #fbfbff; }
.day-cell.is-out { background: #fcfcfe; }
.day-cell.is-out .day-num { color: #c3c8d8; }
.day-cell.is-selected { box-shadow: inset 0 0 0 2px var(--primary); background: #fafaff; }
.day-cell.is-today .day-num {
  background: var(--primary); color: #fff;
  box-shadow: 0 4px 10px rgba(79, 70, 229, .3);
}

.day-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; }

.day-num {
  width: 22px; height: 22px;
  border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
}

.day-flags { display: inline-flex; gap: 4px; align-items: center; min-width: 0; overflow: hidden; }
.day-flags .flag { flex: 0 0 auto; white-space: nowrap; }

.flag {
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  line-height: 1.5;
}
.flag-conflict { background: var(--danger-soft); color: var(--danger); }
.flag-count { background: var(--surface-soft); color: var(--muted); }

.chips { display: flex; flex-direction: column; gap: 3px; min-width: 0; overflow: hidden; }

.chip {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  border: none;
  border-left: 3px solid var(--c, var(--primary));
  background: #f2f3fb;
  background: color-mix(in srgb, var(--c, #4f46e5) 11%, #ffffff);
  color: #2a2f45;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11.5px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  transition: filter .14s, transform .1s;
}
.chip:hover { filter: brightness(.95); }
.chip:active { transform: scale(.985); }
.chip .chip-time { color: #5c6478; font-variant-numeric: tabular-nums; flex: 0 0 auto; font-size: 10.5px; }
.chip .chip-title { overflow: hidden; text-overflow: ellipsis; }
.chip.is-conflict {
  background: var(--danger-soft);
  border-left-color: var(--danger);
  color: #a72b30;
  font-weight: 600;
}
.chip.is-done { opacity: .55; text-decoration: line-through; }

.chip-more {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  text-align: left;
  padding: 0 4px;
  cursor: pointer;
  font-family: inherit;
}
.chip-more:hover { color: var(--primary); }

.calendar-legend {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 12px;
  color: var(--muted);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-conflict { background: var(--danger); }
.dot-today { background: var(--primary); }
.dot-trip { background: var(--trip); }

/* ---------- 出差标识 ---------- */
/* 福州市内 / 福州市外都属于出差，统一使用同一套醒目色（不做二级区分） */

/* 月历日期上的醒目角标 */
.flag-trip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--trip);
  color: #fff;
  box-shadow: 0 1px 3px rgba(234, 88, 12, .35);
}
.flag-trip svg { flex: 0 0 auto; }

/* 当天有出差时日期数字一并高亮，扫一眼即可定位 */
.day-cell.has-trip .day-num { background: var(--trip-soft); color: var(--trip); }

/* 月历色块：以描边 + 飞机图标标记，保留负责人自身的颜色作为底色 */
.chip.is-trip { box-shadow: inset 0 0 0 1px var(--trip-border); }
.chip-plane { display: inline-flex; align-items: center; flex: 0 0 auto; color: var(--trip); }

/* 当日时间轴 */
.tl-block.is-trip { box-shadow: 0 0 0 1.5px var(--trip) inset; }
.tl-allday.is-trip {
  background: repeating-linear-gradient(45deg,
    rgba(234, 88, 12, .3), rgba(234, 88, 12, .3) 6px,
    rgba(234, 88, 12, .12), rgba(234, 88, 12, .12) 12px);
  border-color: var(--trip);
}

/* 当日明细行（此处的 is-conflict 规则在其后定义，冲突样式仍会胜出） */
.task-line.is-trip { background: var(--trip-soft); }

/* 表单中的出差标识下拉框（保持常规宽度，避免整行拉伸） */
.select-narrow { width: auto; min-width: 168px; }

/* ---------- 侧栏面板 ---------- */

.panel { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }

/* 右侧当日安排面板占满整列高度，内容超出时面板内部滚动 */
#day-panel { flex: 1 1 auto; min-height: 0; }

.panel-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px 11px;
  border-bottom: 1px solid var(--border);
}
.panel-head h3 { font-size: 15px; font-weight: 700; }
.panel-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.panel-head-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.panel-body { flex: 1 1 auto; min-height: 0; padding: 12px 16px 16px; overflow-y: auto; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-soft);
  color: var(--muted);
}
.badge-danger { background: var(--danger-soft); color: var(--danger); }

/* 当日成员行 */
.member-row {
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.member-row:last-child { border-bottom: none; }

.member-row-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
}
.member-row-name { font-size: 13px; font-weight: 700; }
.member-row-role { font-size: 11.5px; color: var(--muted); }
.member-row-head .spacer { flex: 1; }

.tl-label { font-size: 10px; color: var(--muted); display: flex; justify-content: space-between; margin-top: 4px; }

.tl {
  position: relative;
  height: 28px;
  border-radius: 8px;
  background:
    repeating-linear-gradient(to right, transparent 0, transparent calc(100% / 12 - 1px), #e9ebf5 calc(100% / 12 - 1px), #e9ebf5 calc(100% / 12)),
    var(--surface-soft);
  border: 1px solid var(--border);
  overflow: hidden;
  margin: 6px 0 2px;
}
.tl-block {
  position: absolute;
  top: 3px; bottom: 3px;
  border-radius: 5px;
  background: var(--c, var(--primary));
  opacity: .9;
  cursor: pointer;
  transition: opacity .14s, transform .1s;
  min-width: 3px;
}
.tl-block:hover { opacity: 1; }
.tl-block.is-conflict {
  background: repeating-linear-gradient(45deg, var(--danger), var(--danger) 5px, #f08a8e 5px, #f08a8e 10px);
  box-shadow: 0 0 0 1.5px var(--danger) inset;
}
.tl-allday {
  position: absolute;
  top: 3px; bottom: 3px; left: 3px; right: 3px;
  border-radius: 5px;
  background: repeating-linear-gradient(45deg, rgba(79,70,229,.28), rgba(79,70,229,.28) 6px, rgba(79,70,229,.12) 6px, rgba(79,70,229,.12) 12px);
  border: 1px dashed var(--primary);
}

.task-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--surface-soft);
  margin-top: 6px;
  border-left: 3px solid var(--c, var(--primary));
  cursor: pointer;
  transition: background .14s;
}
.task-line:hover { background: #eef0fa; }
.task-line-time {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
  white-space: nowrap;
}
.task-line-title { font-size: 12.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-line.is-conflict { background: var(--danger-soft); border-left-color: var(--danger); }

.empty { padding: 16px 6px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ---------- 产出成果 ---------- */

.deliverable-block {
  background: var(--surface-soft);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 11px 12px;
}
.field-gap { margin-top: 8px; }

.file-picker { display: flex; align-items: center; gap: 8px; min-width: 0; }
.file-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-name.is-set { color: var(--text); font-weight: 600; }

.file-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 44%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-family: inherit;
  color: var(--text-soft);
  white-space: nowrap;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, background .15s, color .15s;
}
.file-chip:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.file-chip svg { flex: 0 0 auto; }
.file-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip-clip { display: inline-flex; align-items: center; flex: 0 0 auto; opacity: .7; }

/* ---------- 模态框 ---------- */

.modal-root { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-mask { position: absolute; inset: 0; background: rgba(20, 24, 45, .45); backdrop-filter: blur(2px); }

.modal {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: pop .18s ease-out;
}
.modal.modal-wide { max-width: 720px; }

@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-body { flex: 1 1 auto; min-height: 0; padding: 16px 18px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal-foot .spacer { flex: 1; margin-right: auto; }

/* ---------- 表单 ---------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.col-span-2 { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-soft); }
.field .req { color: var(--danger); }
.field .opt { font-weight: 400; color: var(--muted); }
.field-hint { font-size: 11.5px; color: var(--muted); }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row input[type="time"] { flex: 1; }

.checkbox {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-soft); cursor: pointer; user-select: none;
}
.checkbox input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }

.form-error {
  grid-column: 1 / -1;
  background: var(--danger-soft);
  color: #a72b30;
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 12.5px;
}

.conflict-preview {
  grid-column: 1 / -1;
  background: #fff8e8;
  border: 1px solid #f5dfa8;
  color: #8a6100;
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 12.5px;
}
.conflict-preview ul { margin: 5px 0 0; padding-left: 18px; }
.conflict-preview li { margin: 2px 0; }

.chip-select { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-select .opt {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 11px 4px 6px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all .15s;
}
.chip-select .opt.is-on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }

/* 成员管理 */
.member-list { display: flex; flex-direction: column; gap: 8px; }
.member-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 11px;
  background: var(--surface-soft);
}
.member-item .info { flex: 1; min-width: 0; }
.member-item .name { font-size: 13.5px; font-weight: 700; }
.member-item .role { font-size: 11.5px; color: var(--muted); }

.color-swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; padding: 0;
  transition: transform .12s, border-color .12s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.is-on { border-color: var(--text); }

/* ---------- Toast ---------- */

.toast-root {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: #23283d;
  color: #fff;
  font-size: 13px;
  border-radius: 10px;
  padding: 10px 15px;
  box-shadow: var(--shadow-lg);
  animation: slideIn .2s ease-out;
  max-width: 320px;
}
.toast.is-danger { background: #b3282d; }
.toast.is-success { background: #0f7f55; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 响应式（始终保持视口内不滚动） ---------- */

/* 中等屏幕：收窄右侧栏，仍然左右并排 */
@media (max-width: 1180px) {
  .layout { grid-template-columns: minmax(0, 1fr) 316px; gap: 14px; padding: 12px 16px 16px; }
  .weekdays span { padding: 7px 0; }
  .calendar-legend { gap: 12px; }
}

/* 窄屏：改为上下排列，两行按比例分配剩余高度 */
@media (max-width: 820px) {
  .app-header { padding: 10px 14px; }
  .toolbar { padding: 10px 14px 0; }
  .month-label { font-size: 16px; }
  .month-hint { display: none; }
  .brand-text p { display: none; }
  .chip .chip-time { display: none; }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1.25fr) minmax(0, 1fr);
    padding: 10px 14px 14px;
    gap: 12px;
  }
  .calendar { grid-auto-rows: minmax(0, 1fr); }
  .day-cell { padding: 4px 4px 5px; }
  .calendar-legend { display: none; }
}

/* 极矮视口：压缩固定区域，保证月历仍有可用高度 */
@media (max-height: 700px) {
  .app-header { padding: 8px 20px; }
  .toolbar { padding: 8px 20px 0; }
  .layout { padding: 8px 20px 12px; }
  .calendar-legend { display: none; }
  .panel-head { padding: 10px 14px 9px; }
  .panel-body { padding: 10px 14px 12px; }
}

@media (max-width: 820px) and (max-height: 700px) {
  .app-header { padding: 8px 14px; }
  .toolbar { padding: 8px 14px 0; }
  .layout { padding: 8px 14px 10px; }
}

/* ===========================================================
   登录态 / 角色相关
   =========================================================== */

.header-actions { align-items: center; }
.divider-v { width: 1px; height: 22px; background: var(--border-strong); margin: 0 3px; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 4px 12px 4px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  font-family: inherit;
  cursor: pointer;
  transition: border-color .16s, background .16s;
}
.user-chip:hover { border-color: var(--border-strong); background: #eef0fa; }
.user-chip .avatar-lg { width: 30px; height: 30px; font-size: 12px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.25; text-align: left; }
.user-meta b { font-size: 13px; font-weight: 700; }
.user-meta i {
  font-style: normal;
  font-size: 10.5px;
  color: var(--muted);
}
.user-meta i.is-admin { color: var(--primary); font-weight: 700; }

/* 下拉箭头 */
.user-chip .caret {
  width: 0; height: 0;
  margin-left: 1px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
  transition: transform .18s;
}
.user-menu:hover .user-chip .caret,
.user-menu.is-open .user-chip .caret { transform: rotate(180deg); }

/* ---------- 用户下拉菜单 ---------- */

.user-menu { position: relative; }

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  /* 顶部留出缓冲，避免鼠标从头像移向菜单时 hover 中断 */
  padding-top: 8px;
  z-index: 70;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity .16s ease, transform .16s ease, visibility .16s;
}

/* 鼠标移入即展开，点击头像则固定展开 */
.user-menu:hover .user-dropdown,
.user-menu.is-open .user-dropdown {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.user-dropdown-inner {
  min-width: 172px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-soft);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s, color .14s;
}
.menu-item:hover { background: var(--primary-soft); color: var(--primary); }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger:hover { background: var(--danger-soft); color: var(--danger); }

/* 菜单项图标 */
.menu-item svg {
  flex: 0 0 auto;
  opacity: .82;
  transition: opacity .14s;
}
.menu-item:hover svg { opacity: 1; }
.menu-item > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--border);
}

.flag-done { background: #e7f8f0; color: var(--success); }

/* 加载遮罩 */
.loading-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(244, 245, 250, .72);
  backdrop-filter: blur(1px);
}
.loading-box {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 13px;
  color: var(--text-soft);
  box-shadow: var(--shadow-md);
}
.spinner {
  width: 15px; height: 15px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===========================================================
   登录页
   =========================================================== */

.auth-body {
  overflow: auto;
  display: block;
  background:
    radial-gradient(1000px 520px at 12% -10%, #e5e8ff 0%, rgba(229, 232, 255, 0) 60%),
    radial-gradient(900px 480px at 100% 0%, #dff2ff 0%, rgba(223, 242, 255, 0) 55%),
    var(--bg);
}

.auth-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 460px) minmax(0, 1fr);
  align-items: center;
  gap: 56px;
  padding: 40px 6vw;
  max-width: 1180px;
  margin: 0 auto;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 34px 32px 26px;
}

.auth-brand { text-align: center; margin-bottom: 24px; }
.brand-logo-lg {
  width: 52px; height: 52px;
  font-size: 22px;
  border-radius: 15px;
  margin: 0 auto 12px;
}
.auth-brand h1 { font-size: 21px; font-weight: 700; letter-spacing: .5px; }
.auth-brand p { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form .field label { font-size: 12.5px; }
.auth-form input { padding: 11px 12px; font-size: 14px; }
.auth-form .form-error { border-radius: 9px; padding: 9px 12px; font-size: 12.5px; background: var(--danger-soft); color: #a72b30; }

.btn-block { width: 100%; padding: 11px 16px; font-size: 14.5px; margin-top: 4px; }

.auth-foot {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

.auth-side h2 { font-size: 26px; font-weight: 700; letter-spacing: .5px; line-height: 1.4; }
.auth-side ul { list-style: none; padding: 0; margin: 22px 0 0; display: flex; flex-direction: column; gap: 13px; }
.auth-side li {
  position: relative;
  padding-left: 26px;
  color: var(--text-soft);
  font-size: 14px;
}
.auth-side li::before {
  content: '';
  position: absolute;
  left: 7px; top: 9px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .13);
}
.auth-side li b { color: var(--text); }

@media (max-width: 980px) {
  .auth-wrap { grid-template-columns: minmax(0, 1fr); gap: 28px; padding: 28px 20px; align-items: start; }
  .auth-side { order: -1; text-align: center; }
  .auth-side ul { display: none; }
  .auth-side h2 { font-size: 20px; }
}

/* ===========================================================
   系统管理页
   =========================================================== */

.admin-body { overflow: auto; display: block; background: var(--bg); }

.admin-main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 24px 40px;
  max-width: 1500px;
  margin: 0 auto;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  border-top: 3px solid var(--border-strong);
}
.stat-card.is-primary { border-top-color: var(--primary); }
.stat-card.is-success { border-top-color: var(--success); }
.stat-card.is-warn { border-top-color: var(--warning); }
.stat-value {
  font-size: 27px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-label { font-size: 12.5px; color: var(--muted); }

.admin-card { display: flex; flex-direction: column; overflow: hidden; }
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-soft);
  padding: 10px 14px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fbfbff; }
.data-table th.num, .data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table th.ops, .data-table td.ops { text-align: right; white-space: nowrap; }
.data-table td.ops .btn { margin-left: 4px; }
.data-table code {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12px;
}
.data-table .empty { text-align: center; color: var(--muted); padding: 26px 0; }
.data-table .muted-cell { color: var(--muted); font-size: 12.5px; }
.data-table .ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cell-user { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-soft);
  color: var(--text-soft);
  border: 1px solid var(--border);
}

/* ---------- 操作日志弹窗 ---------- */

.modal.modal-logs { max-width: 920px; }

.logs-modal { display: flex; flex-direction: column; gap: 12px; min-height: 0; }

.logs-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.page-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.page-size select { width: auto; padding: 4px 8px; font-size: 12.5px; }

.logs-table-wrap {
  max-height: min(52vh, 440px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.logs-table-wrap .data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 30px;
}
.page-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 8px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--text-soft);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.page-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}
.page-btn:disabled { opacity: .42; cursor: not-allowed; }
.page-btn.page-num { padding: 0; }
.page-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
}
.page-gap { color: var(--muted); padding: 0 2px; }
.page-info { font-size: 12.5px; color: var(--muted); }
.tag-admin { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.tag-on { background: #e7f8f0; color: var(--success); border-color: transparent; }
.tag-off { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* ---------- 薪资管理 ---------- */

.tab-bar {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  align-self: flex-start;
}

.tab-btn {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  padding: 7px 18px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

.tab-pane { display: flex; flex-direction: column; min-width: 0; }

.card-body { padding: 16px 18px 18px; }

.inline-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.sub-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 10px;
}
.sub-head h4 { font-size: 13.5px; font-weight: 700; }
.sub-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* 五险表格内的输入框 */
.insurance-table .cell-input {
  width: 100%;
  max-width: 132px;
  margin-left: auto;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 12.5px;
  font-family: inherit;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.insurance-table .cell-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .13);
}
.insurance-table.is-readonly .cell-input { background: var(--surface-soft); color: var(--muted); }
.insurance-table tfoot th {
  background: var(--surface-soft);
  font-size: 12.5px;
  border-top: 1px solid var(--border);
}

.salary-totals { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.salary-total {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 168px;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 14px;
  background: var(--surface-soft);
}
.salary-total.is-primary { border-color: #dfe2ff; background: var(--primary-soft); }
.st-label { font-size: 11.5px; color: var(--muted); }
.st-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.salary-total.is-primary .st-value { color: var(--primary); }

.cell-note { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.amount-strong { font-weight: 700; color: var(--primary); }

/* 比例设置：折算预览 */
.ratio-preview {
  display: flex;
  align-items: center;
  min-height: 36px;
  border: 1px dashed var(--border-strong);
  border-radius: 9px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-soft);
  background: var(--surface-soft);
}
.ratio-preview b { color: var(--primary); font-variant-numeric: tabular-nums; }

/* 工资条详情：试用期折算说明 */
.payslip-probation {
  margin-top: 12px;
  border: 1px dashed #dfe2ff;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
  color: #3f3d8f;
  background: var(--primary-soft);
}
.payslip-probation b { color: var(--primary); font-variant-numeric: tabular-nums; }

/* 工资条汇总 */
.payslip-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 9px;
  margin: 12px 0 14px;
}
.ps-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  background: var(--surface-soft);
}
.ps-cell.is-strong { border-color: #dfe2ff; background: var(--primary-soft); }
.ps-label { font-size: 11.5px; color: var(--muted); }
.ps-value { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ps-cell.is-strong .ps-value { color: var(--primary); }

.payslip-detail .payslip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.payslip-name { font-size: 16px; font-weight: 700; }
.payslip-period { font-size: 12px; color: var(--muted); margin-top: 2px; }
.payslip-net { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.payslip-net .st-value { font-size: 22px; color: var(--primary); }

.items-table .items-group td {
  background: var(--surface-soft);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  padding: 6px 14px;
}

.payslip-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 820px) {
  .admin-main { padding: 14px 14px 30px; }
  .user-meta { display: none; }
  .user-chip { padding: 4px; }
  .sub-head { flex-direction: column; align-items: flex-start; }
}
