/* ===================== 基础 ===================== */
:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --border: #e3e8f0;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;

  --day: #3b82f6;
  --day-bg: #eff6ff;
  --night: #6d28d9;
  --night-bg: #f5f3ff;
  --rest: #9ca3af;
  --rest-bg: #f3f4f6;
  --leave: #f59e0b;
  --leave-bg: #fffbeb;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

h1, h2, h3 { margin: 0; font-weight: 600; }

/* ===================== 顶栏 ===================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.logo {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  border-radius: 10px;
  font-weight: 700;
  font-size: 18px;
}

.brand h1 { font-size: 17px; }
.brand .sub { margin: 0; font-size: 12px; color: var(--muted); }

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

.nav-link {
  padding: 7px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: .15s;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--primary); color: #fff; }

/* ===================== 布局 ===================== */
.layout {
  display: grid;
  grid-template-columns: 1fr 330px;
  gap: 18px;
  padding: 18px 24px 32px;
  max-width: 1600px;
  margin: 0 auto;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h2 { font-size: 18px; }
.panel-desc { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.panel-title { font-size: 16px; margin-bottom: 14px; }

.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav h2 { font-size: 18px; min-width: 110px; text-align: center; }

.btn-icon {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
  transition: .15s;
}
.btn-icon:hover { background: var(--bg); border-color: #cbd5e1; }

.btn-text {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
}
.btn-text:hover { background: #eff6ff; }

.btn-primary {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: .15s;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-small {
  border: 1px solid var(--border);
  background: #fff;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: .15s;
}
.btn-small:hover { background: var(--bg); border-color: #cbd5e1; }
.btn-danger-lite { color: #b91c1c; border-color: #fecaca; }
.btn-danger-lite:hover { background: #fef2f2; border-color: #fca5a5; }

/* ===================== 员工专属链接 ===================== */
.token-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.token-spacer { flex: 1; }
.token-count { font-size: 12.5px; color: var(--muted, #64748b); }

.token-list { display: flex; flex-direction: column; gap: 8px; }
.token-list .empty { text-align: center; color: var(--muted, #64748b); font-size: 13px; padding: 22px 8px; margin: 0; }

.token-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border: 1px solid var(--border, #e2e8f0);
  border-radius: 9px; background: #fff; transition: .15s;
}
.token-row:hover { border-color: #bfdbfe; background: #f8fbff; }
.token-row.is-revoked { background: #f8fafc; opacity: .62; }

.token-who { flex: 0 0 168px; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.token-name { font-size: 13.5px; font-weight: 600; color: #1e293b; }
.token-meta { font-size: 11px; color: var(--muted, #64748b);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.token-link {
  flex: 1 1 auto; min-width: 0;
  border: 1px solid var(--border, #e2e8f0); border-radius: 7px;
  padding: 6px 9px; font-size: 11.5px; color: #475569;
  background: #f8fafc; font-family: ui-monospace, Menlo, Consolas, monospace;
}
.token-row.is-revoked .token-link { text-decoration: line-through; }

/* 账号密码列 */
.token-acct { flex: 0 0 218px; display: flex; gap: 5px; align-items: center; min-width: 0; }
.token-pw {
  flex: 1 1 auto; min-width: 0;
  border: 1px solid var(--border, #e2e8f0); border-radius: 7px;
  padding: 6px 9px; font-size: 12px; color: #334155;
}
.token-pw:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); outline: none; }
.token-pw::placeholder { color: #94a3b8; font-size: 11px; }

.token-ops { flex: 0 0 auto; display: flex; gap: 5px; }
.btn-chip {
  border: 1px solid var(--border, #e2e8f0); background: #fff;
  padding: 5px 10px; border-radius: 7px; cursor: pointer;
  font-size: 12px; transition: .15s; white-space: nowrap;
}
.btn-chip:hover { background: var(--bg, #f1f5f9); }
.btn-chip.warn { color: #b45309; border-color: #fde68a; }
.btn-chip.warn:hover { background: #fffbeb; }
.btn-chip.ok { color: #047857; border-color: #a7f3d0; }
.btn-chip.ok:hover { background: #ecfdf5; }

@media (max-width: 820px) {
  .token-row { flex-wrap: wrap; }
  .token-who { flex: 1 1 auto; }
  .token-link { flex: 1 1 100%; order: 3; }
  .token-acct { flex: 1 1 100%; order: 4; }
  .token-ops { order: 5; width: 100%; justify-content: flex-end; }
}

/* ===================== 图例 ===================== */
.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.lg { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* 日历上方的名额图例说明 */
.cal-hint {
  font-size: 11.5px; color: var(--muted, #64748b); line-height: 1.9;
  padding: 7px 10px; margin-bottom: 10px;
  background: #f8fafc; border: 1px solid var(--border, #e2e8f0); border-radius: 8px;
}
.cal-hint .grp-chip { vertical-align: middle; margin: 0 1px; }
.cal-hint b { color: #334155; }

/* 班次颜色 */
.shift-day { background: var(--day); }
.shift-night { background: var(--night); }
.shift-rest { background: var(--rest); }
.shift-leave { background: var(--leave); }

.dot.shift-rest { background: #d1d5db; }

/* ===================== 日历 ===================== */
.cal-weekhead {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.cal-weekhead > div {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.cal-cell {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 128px;
  padding: 8px 9px;
  position: relative;
  transition: .15s;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}

.cal-cell.out-month { background: #fafbfc; border-color: #f1f3f7; min-height: 128px; }
.cal-cell.out-month .cell-date { color: #d1d5db; }

.cal-cell.in-month.clickable { cursor: pointer; }
.cal-cell.in-month.clickable:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
  transform: translateY(-1px);
}

.cal-cell.is-today { border-color: var(--primary); border-width: 2px; }
.cal-cell.is-today .cell-date {
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 22px; height: 22px;
  display: grid; place-items: center;
}

.cal-cell.is-mine { background: #fffdf5; border-color: #fcd34d; }

/* 不可选公休的月份：灰化并禁止点击 */
.cal-cell.in-month.locked { opacity: .72; }
.cal-cell.in-month.locked .cell-shift-name { filter: grayscale(.35); }
.cal-cell.in-month.locked:hover { border-color: var(--border); box-shadow: none; transform: none; }
/* 公休开始日期之前：斜纹灰底 + 不可点 */
.cal-cell.in-month.before-start {
  opacity: .55;
  background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 6px, #eef2f7 6px, #eef2f7 12px);
  cursor: not-allowed;
}
.cal-cell.in-month.before-start .cell-shift-name { filter: grayscale(.6); }
/* 公休排假未开放：整月斜纹锁定 */
.cal-cell.in-month.not-open {
  background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 6px, #eef2f7 6px, #eef2f7 12px);
}

.cell-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.cell-date { font-size: 13px; font-weight: 600; color: #374151; flex-shrink: 0; }

.cell-badges { display: flex; align-items: center; gap: 4px; }

.shift-badge {
  font-size: 11px;
  color: #fff;
  padding: 1px 6px;
  border-radius: 5px;
  font-weight: 500;
  line-height: 1.5;
}
.shift-badge.shift-rest { background: #d1d5db; color: #4b5563; }

.mine-tag {
  font-size: 10px;
  background: var(--leave);
  color: #fff;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 600;
}

.cell-warn { color: var(--danger); font-size: 13px; cursor: help; }

.cell-shift-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  border-radius: 6px;
  text-align: center;
  padding: 2px 0;
  opacity: .92;
}
.cell-shift-name.shift-rest { background: #e5e7eb; color: #9ca3af; }

.cell-roster {
  margin-top: auto;
  font-size: 11px;
  line-height: 1.5;
  color: #b45309;
  background: var(--leave-bg);
  border-radius: 5px;
  padding: 1px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* 该日各组已选休假人数：转1/3 · 压2/2 */
.cell-groups {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}
.grp-chip {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  font-size: 10.5px;
  line-height: 1.4;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--leave-bg, #fef3c7);
  color: #b45309;
  border: 1px solid #fde68a;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
}
.grp-chip b { font-weight: 700; font-size: 11px; }
/* 本人所在组：加深底色，一眼看出自己组还剩几个名额 */
.grp-chip.mine { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
/* 名额已满：转红，提示不可再选 */
.grp-chip.full { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.grp-chip.mine.full { background: #fecaca; color: #991b1b; border-color: #f87171; }

/* 管理端日历：班次用背景色 + 顶部色条区分 */
.admin-cal .cal-cell { min-height: 104px; }

.cal-cell.admin.acell-day { background: var(--day-bg); border-top: 3px solid var(--day); }
.cal-cell.admin.acell-night { background: var(--night-bg); border-top: 3px solid var(--night); }
.cal-cell.admin.acell-rest { background: #f3f4f6; border-top: 3px solid #cbd5e1; }

.cal-cell.admin.has-warn { background: #fef2f2; border-color: #fca5a5; border-top-color: var(--danger); }

.cal-cell.admin.is-today { border-width: 1px; border-top-width: 3px; }
.cal-cell.admin.is-today .cell-date {
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 22px; height: 22px;
  display: grid; place-items: center;
}

.legend-day { background: var(--day); }
.legend-night { background: var(--night); }
.legend-rest { background: #cbd5e1; }

.cell-metrics { display: flex; gap: 8px; white-space: nowrap; }
.metric { font-size: 11px; color: var(--muted); }
.metric b { color: #374151; margin-left: 1px; }
.metric.leave-m b { color: #b45309; }

.cell-names {
  font-size: 10.5px;
  line-height: 1.45;
  color: #4b5563;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.cell-names.lv { color: #b45309; }

.p-post {
  font-style: normal;
  font-size: 9px;
  opacity: .62;
  margin-left: 1px;
}

.cell-warnbar {
  font-size: 10px;
  color: var(--danger);
  background: #fee2e2;
  border-radius: 4px;
  padding: 1px 5px;
  margin-top: auto;
}

/* 可点击的日期格：悬停/聚焦反馈 */
.cal-cell.admin.clickable { cursor: pointer; transition: box-shadow .15s, transform .15s; }
.cal-cell.admin.clickable:hover {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, .45) inset;
  transform: translateY(-1px);
  z-index: 2;
}
.cal-cell.admin.clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.cal-cell.admin.clickable::after {
  content: '…';
  position: absolute;
  top: 3px; right: 5px;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  opacity: 0;
  transition: opacity .15s;
}
.cal-cell.admin.clickable:hover::after { opacity: .7; }

.cal-tip { font-size: 12px; color: var(--muted); margin: 10px 2px 0; }

/* ===================== 弹窗 ===================== */
/* 弹窗打开时锁定页面滚动（配合 JS 的 position:fixed + top 记录） */
body.modal-open {
  position: fixed;
  width: 100%;
  overflow: hidden;
  touch-action: none;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 200;
  animation: modalFade .16s ease-out;
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--panel);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, .22);
  width: min(560px, 100%);
  max-height: min(80vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalRise .18s ease-out;
  overscroll-behavior: contain;
}
@keyframes modalRise { from { transform: translateY(10px); opacity: .6; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #f8fafc, #fff);
}
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  border-radius: 6px;
}
.modal-close:hover { background: #f1f5f9; color: var(--text); }

.modal-body { padding: 16px 20px 20px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 12px 20px 16px; border-top: 1px solid var(--border); background: #fbfcfe;
}
.modal-foot .btn-primary { min-width: 96px; }

.dm-shift {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 99px;
  margin-bottom: 14px;
}
.dm-shift.dm-day { background: var(--day-bg); color: #1d4ed8; border: 1px solid #bfdbfe; }
.dm-shift.dm-night { background: var(--night-bg); color: #6d28d9; border: 1px solid #ddd6fe; }
.dm-shift.dm-rest { background: var(--rest-bg); color: #475569; border: 1px solid #e2e8f0; }

.dm-sec { margin-bottom: 16px; }
.dm-sec:last-child { margin-bottom: 0; }
.dm-sec-title {
  font-size: 13px;
  font-weight: 700;
  color: #374151;
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.dm-sec-title .dm-count {
  font-weight: 600;
  font-size: 11.5px;
  color: var(--muted);
  background: #f1f5f9;
  border-radius: 99px;
  padding: 1px 8px;
}

.dm-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 10px 0 6px;
}
.dm-group-title:first-child { margin-top: 0; }

.dm-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.dm-chip {
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  color: #334155;
}
.dm-chip i { font-style: normal; font-size: 10.5px; opacity: .6; margin-left: 2px; }
/* 工种标记：用弱化的方框与岗位区分 */
.dm-chip i.dm-trade {
  background: rgba(148, 163, 184, .18);
  border-radius: 3px;
  padding: 0 4px;
  opacity: .85;
  font-weight: 500;
}
.dm-chip.chip-rest { background: #f3f4f6; color: #64748b; }
.dm-chip.chip-leave { background: var(--leave-bg); border-color: #fde68a; color: #b45309; font-weight: 600; }

.dm-empty { font-size: 12.5px; color: var(--muted); padding: 2px 0; }

.dm-warn {
  font-size: 12.5px;
  color: var(--danger);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 8px 11px;
  margin-bottom: 14px;
}

/* ===================== 侧栏 ===================== */
.side-panel { position: sticky; top: 84px; }

/* ---- 身份区（由专属链接绑定） ---- */
.id-box {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; margin-bottom: 14px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #bfdbfe; border-radius: 10px;
}
.id-avatar {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary, #2563eb); color: #fff;
  font-size: 16px; font-weight: 600;
}
.id-meta { min-width: 0; flex: 1; }
.id-name { font-size: 15px; font-weight: 700; color: #1e3a8a; line-height: 1.3; }
.id-sub { font-size: 11.5px; color: #3b5f9e; margin-top: 2px; line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.id-lock {
  flex: 0 0 auto; font-size: 10.5px; padding: 2px 7px; border-radius: 999px;
  background: #1e3a8a; color: #fff; letter-spacing: .5px;
}
.id-ops {
  flex: 0 0 auto; display: flex; flex-direction: column; gap: 4px; align-items: stretch;
}
.id-logout {
  flex: 0 0 auto; font-size: 11px; padding: 4px 9px; border-radius: 999px;
  border: 1px solid #93c5fd; background: #fff; color: #1d4ed8; cursor: pointer;
  white-space: nowrap;
}
.id-logout:hover { background: #dbeafe; }

/* 绑定方式标签页 */
.bind-tabs {
  display: flex; gap: 6px; justify-content: center;
  background: #eef2f7; border-radius: 9px; padding: 4px; margin-bottom: 12px;
}
.bind-tab {
  flex: 1; border: none; background: transparent; cursor: pointer;
  font-size: 12.5px; padding: 7px 4px; border-radius: 7px; color: #64748b; transition: .15s;
}
.bind-tab.active { background: #fff; color: #1e3a8a; font-weight: 700; box-shadow: 0 1px 3px rgba(15,23,42,.12); }

#bindAccount .field { margin-bottom: 10px; }
#bindAccount .btn-primary { width: 100%; margin-bottom: 8px; }
#bindAccount .dim, #bindLink .dim { text-align: left; }

.id-empty {
  text-align: center; padding: 22px 14px 18px;
  border: 1px dashed #c7d2fe; border-radius: 10px;
  background: #f8fafc; margin-bottom: 14px;
}
.id-empty-icon { font-size: 26px; margin-bottom: 6px; }
.id-empty p { font-size: 13px; color: #334155; margin: 0 0 6px; line-height: 1.7; }
.id-empty p.dim { font-size: 12px; color: var(--muted, #64748b); margin-bottom: 10px; }

/* 帮助弹窗 */
.link-help-back { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 900; }
.link-help {
  position: fixed; z-index: 901; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92vw, 380px); background: #fff; border-radius: 14px;
  padding: 20px 20px 16px; box-shadow: 0 20px 50px rgba(15,23,42,.28);
}
.link-help h3 { margin: 0 0 12px; font-size: 15.5px; color: #1e3a8a; }
.link-help ol { margin: 0 0 10px; padding-left: 18px; }
.link-help li { font-size: 13px; color: #334155; line-height: 1.85; }
.link-help p.dim { font-size: 12px; color: var(--muted, #64748b); line-height: 1.7; margin: 0 0 12px; }
.link-help-hit {
  font-size: 12px; color: #92400e; background: #fef3c7;
  border: 1px solid #fde68a; border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; line-height: 1.7;
}
.link-help code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
.link-help .btn-primary { width: 100%; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 500; color: #374151; }
.field small { font-size: 11.5px; color: var(--muted); line-height: 1.5; }

.field select,
.field input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: .15s;
  width: 100%;
}
.field select:focus,
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

/* 只读的计算字段（如「单日全员总上限」） */
.field input.readonly-input,
.field input[readonly] {
  background: #f1f5f9;
  color: var(--muted, #64748b);
  cursor: not-allowed;
  font-weight: 700;
}
.field input[readonly]:focus { border-color: var(--border); box-shadow: none; }

/* 导出 Excel 按钮（绿色，与 CSV 区分） */
.btn-excel {
  background: #059669 !important;
  color: #fff !important;
  border-color: #047857 !important;
}
.btn-excel:hover { background: #047857 !important; }

.leave-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: #fcfdff;
}

.leave-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.leave-name { font-size: 17px; font-weight: 700; }
.leave-group { font-size: 12px; color: var(--muted); }

.leave-count { text-align: right; font-size: 20px; font-weight: 700; color: var(--primary); line-height: 1.1; }
.slash { color: #cbd5e1; font-weight: 400; }
.leave-count-label { font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 2px; }

.progress { height: 6px; background: #e5e7eb; border-radius: 99px; overflow: hidden; margin-bottom: 14px; }
.progress-bar { height: 100%; background: var(--primary); transition: width .3s, background .3s; border-radius: 99px; }
.progress-bar.full { background: var(--leave); }

.leave-list-wrap { margin-bottom: 14px; }
.leave-list-title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }

.leave-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 26px; }

.leave-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--leave-bg);
  border: 1px solid #fcd34d;
  color: #b45309;
  border-radius: 6px;
  padding: 2px 4px 2px 8px;
  font-size: 12px;
  font-weight: 500;
}
.leave-chip button {
  border: none; background: transparent; color: #b45309;
  cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px; border-radius: 4px;
}
.leave-chip button:hover { background: #fde68a; }

.empty { font-size: 12px; color: #9ca3af; }

.daystat { border-top: 1px dashed var(--border); padding-top: 12px; margin-bottom: 12px; }
.daystat-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.daystat-body { display: flex; flex-wrap: wrap; gap: 5px; }

.stat-chip {
  font-size: 11px;
  background: var(--bg);
  border-radius: 5px;
  padding: 2px 6px;
  color: #4b5563;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.stat-chip .n { background: #e5e7eb; border-radius: 4px; padding: 0 4px; font-weight: 600; font-size: 10px; }
.stat-chip.mine { background: var(--leave-bg); color: #b45309; }
.stat-chip.mine .n { background: #fde68a; }

/* 可点击的统计块：悬停反馈 */
.stat-chip.clickable { cursor: pointer; transition: box-shadow .15s, transform .15s, background .15s; }
.stat-chip.clickable:hover {
  background: var(--leave-bg);
  color: #b45309;
  box-shadow: 0 0 0 1px #fcd34d;
  transform: translateY(-1px);
}
.stat-chip.clickable:hover .n { background: #fde68a; }
.stat-chip.clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.hint {
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 8px;
  padding: 9px 11px;
  line-height: 1.6;
}
.hint b { color: var(--text); }

.hint .hint-line {
  color: #1e40af;
  font-weight: 500;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}

.side-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 10px; line-height: 1.9; }

.panel-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
}
.warn-text { color: #b45309; }

/* ===================== 登录 ===================== */
.login-wrap { display: grid; place-items: center; min-height: calc(100vh - 70px); padding: 24px; }

.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 34px 32px;
  width: 100%;
  max-width: 380px;
}
.login-card h2 { font-size: 20px; margin-bottom: 6px; }
.login-sub { font-size: 12.5px; color: var(--muted); margin: 0 0 22px; }
.login-sub code { background: var(--bg); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.login-card .btn-primary { width: 100%; margin-top: 6px; }
.login-err { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-top: 10px; text-align: center; }

/* ===================== 管理端布局 ===================== */
.admin-layout { max-width: 1400px; margin: 0 auto; padding: 18px 24px 40px; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; background: #fff; padding: 5px; border-radius: 10px; border: 1px solid var(--border); width: fit-content; }

.tab {
  border: none;
  background: transparent;
  padding: 8px 20px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: .15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--primary); color: #fff; }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* 分组 */
.group-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }

/* grid 子项默认 min-width:auto 会被内容撑开，必须显式归零才能随容器收缩 */
.group-grid > * { min-width: 0; }

.group-box { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: #fcfdff; min-width: 0; overflow: hidden; }

.group-box-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; flex-wrap: wrap; }

.group-name-input {
  border: none;
  background: transparent;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  outline: none;
  border-bottom: 2px solid transparent;
  padding: 2px 4px;
  width: 130px;
  transition: .15s;
}
.group-name-input:focus { border-bottom-color: var(--primary); }

.member-count { font-size: 12px; color: var(--muted); }
.member-count b { color: var(--primary); font-size: 15px; }

.member-tags { display: flex; flex-wrap: wrap; gap: 7px; min-height: 60px; padding: 10px; background: #fff; border: 1px dashed var(--border); border-radius: 9px; margin-bottom: 10px; align-content: flex-start; }

.member-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 3px 4px 3px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
}
.member-tag .tag-name { white-space: nowrap; }

/* 岗位配色 */
.member-tag.post-leader { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.member-tag.post-relief { background: #f5f3ff; border-color: #ddd6fe; color: #6d28d9; }
.member-tag.post-main { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.member-tag.post-sub { background: #f8fafc; border-color: #e2e8f0; color: #475569; }

.tag-post {
  border: none;
  background: rgba(255,255,255,.75);
  border-radius: 5px;
  font-size: 11px;
  font-family: inherit;
  color: inherit;
  padding: 1px 2px;
  cursor: pointer;
  outline: none;
  max-width: 74px;
}
.tag-post:hover { background: #fff; }

/* 工种下拉：与岗位区分，用偏中性的底色调 */
.tag-trade {
  border: 1px solid rgba(148, 163, 184, .45);
  background: #fff;
  border-radius: 5px;
  font-size: 11px;
  font-family: inherit;
  color: #475569;
  padding: 1px 2px;
  cursor: pointer;
  outline: none;
  max-width: 78px;
}
.tag-trade:hover { border-color: #94a3b8; }

.tag-sels { display: inline-flex; align-items: center; gap: 3px; }

.member-add { display: flex; gap: 8px; flex-wrap: wrap; }
.member-add input {
  flex: 1 1 110px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.member-add input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

.post-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: #fff;
  flex-shrink: 0;
}
.post-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.member-tag button {
  border: none; background: transparent; color: #60a5fa; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 4px; border-radius: 4px;
}
.member-tag button:hover { background: #dbeafe; color: var(--danger); }

.member-add { display: flex; gap: 8px; }
.member-add input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.member-add input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

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

/* 配置 */
.config-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; margin-bottom: 22px; }

/* 各组独立上限输入 */
.grouplimit-row { display: flex; gap: 10px; flex-wrap: wrap; }

.grouplimit-item {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg);
  border-radius: 8px;
  padding: 5px 8px 5px 11px;
  flex: 1;
  min-width: 108px;
}

.grouplimit-name {
  font-size: 12.5px;
  color: #374151;
  font-weight: 500;
  white-space: nowrap;
}

.grouplimit-item input {
  width: 62px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: #fff;
  text-align: center;
}
.grouplimit-item input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

/* 「各组 × 各班次」在岗下限矩阵 */
.field-wide { grid-column: 1 / -1; }

.onduty-grid { display: inline-flex; flex-direction: column; gap: 6px; }

.onduty-row { display: grid; grid-template-columns: 84px 92px 92px; gap: 8px; align-items: center; }

.onduty-head .onduty-shift { font-size: 12px; color: var(--muted); text-align: center; }

.onduty-group { font-size: 12.5px; color: #374151; font-weight: 500; }

.onduty-row input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: #fff;
  text-align: center;
  width: 100%;
}
.onduty-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

/* 「各组 × 岗位」当日休假上限 */
.postlimit-grid { display: flex; flex-direction: column; gap: 8px; width: 100%; }

.postlimit-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--bg);
  border-radius: 8px;
  padding: 7px 10px;
}

.postlimit-groupname {
  font-size: 12.5px;
  color: #374151;
  font-weight: 600;
  white-space: nowrap;
  min-width: 56px;
}

.postlimit-items { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }

.postlimit-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 3px 8px 3px 10px;
}

.postlimit-name { font-size: 12.5px; color: #374151; white-space: nowrap; }

.postlimit-item input {
  width: 54px;
  border: none;
  border-radius: 5px;
  padding: 5px 6px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: transparent;
  text-align: center;
  color: var(--text);
}
.postlimit-item input::placeholder { color: #9ca3af; font-size: 12px; }
.postlimit-item:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

.cfg-preview {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.cycle-chip {
  color: #fff;
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 500;
}
.cycle-chip.shift-rest { background: #d1d5db; color: #4b5563; }

/* 统计卡 */
.stat-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.stat-card {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
}
.stat-card.warn { background: #fef2f2; }
.stat-num { font-size: 24px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat-card.warn .stat-num { color: var(--danger); }
.stat-lb { font-size: 12px; color: var(--muted); margin-top: 2px; }

.stat-alert {
  grid-column: 1 / -1;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #b45309;
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 12.5px;
  line-height: 1.7;
}

/* ===================== Toast ===================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(20px);
  background: #1f2937;
  color: #fff;
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: .25s;
  z-index: 999;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { background: #059669; }
.toast-error { background: var(--danger); }

/* ===================== 响应式 ===================== */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .side-panel { position: static; }
}

@media (max-width: 820px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand { gap: 8px; }
  .brand .sub { display: none; }
  .brand h1 { font-size: 15px; }
  .logo { width: 32px; height: 32px; font-size: 15px; border-radius: 8px; }
  .nav-link { padding: 6px 10px; font-size: 12px; }

  .layout, .admin-layout { padding: 10px 10px 24px; gap: 12px; }
  .panel { padding: 12px; border-radius: 10px; }
  .panel-head { gap: 8px; }
  .panel-title { font-size: 15px; }

  .month-nav { width: 100%; flex-wrap: wrap; }
  .month-nav h2 { font-size: 16px; min-width: 0; flex: 1; }
  .btn-icon { width: 34px; height: 34px; }

  .legend { gap: 8px; }
  .lg { font-size: 11px; gap: 4px; }

  .cal-weekhead { gap: 4px; margin-bottom: 4px; }
  .cal-weekhead > div { font-size: 11px; padding: 4px 0; }
  .cal-grid { gap: 4px; }
  .cal-cell { min-height: 96px; padding: 5px 4px; gap: 3px; border-radius: 8px; }
  .cal-cell.out-month { min-height: 96px; }
  .cell-date { font-size: 12px; }
  .cal-cell.is-today .cell-date { width: 20px; height: 20px; }
  .cell-shift-name { font-size: 12px; border-radius: 5px; padding: 2px 0; }
  .cell-roster { font-size: 9.5px; padding: 1px 4px; }
  .mine-tag { width: 15px; height: 15px; font-size: 9px; }
  .cell-warn { font-size: 12px; }

  /* 手机：格子窄，分组徽章竖排铺满格宽，小字号保证完整可读 */
  .cell-groups { flex-direction: column; align-items: stretch; gap: 1px; }
  .grp-chip { justify-content: center; font-size: 9.5px; padding: 1px 2px; border-radius: 3px; }
  .grp-chip b { font-size: 10px; }
  .cal-hint { font-size: 11px; padding: 6px 8px; }

  /* 管理端日历（手机）：仅保留公休数，避免窄格挤压 */
  .admin-cal .cal-cell { min-height: 88px; padding: 4px 5px; }
  .admin-cal .metric:not(.leave-m) { display: none; }
  .cell-metrics { gap: 4px; }
  .metric { font-size: 10px; }
  .cell-names { font-size: 10px; -webkit-line-clamp: 2; }
  .cell-warnbar { font-size: 9px; padding: 1px 4px; }
  .legend { width: 100%; order: 3; }

  .side-panel { order: -1; }
  .leave-card { padding: 12px; }
  .panel-foot { font-size: 11.5px; }

  .group-grid { grid-template-columns: 1fr; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 8px 10px; font-size: 13px; }
  .config-grid { grid-template-columns: 1fr; gap: 12px; }
  .stat-summary { grid-template-columns: repeat(2, 1fr); }

  /* 人员卡片：手机上工种/岗位下拉与姓名换行堆叠，避免横向溢出 */
  .group-box { padding: 12px; }
  .member-tags { gap: 6px; padding: 8px; }
  .member-tag { font-size: 12px; padding: 4px 4px 4px 9px; gap: 4px; max-width: 100%; flex-wrap: wrap; }
  .tag-sels { flex-wrap: wrap; }
  .tag-post, .tag-trade { font-size: 10.5px; max-width: 66px; }
  .member-add { gap: 6px; }
  .member-add input { flex: 1 1 100%; }
  .post-select { flex: 1 1 auto; min-width: 0; max-width: none; padding: 8px 4px; font-size: 12.5px; }
  .member-add .btn-small { flex: 0 0 auto; }

  /* 岗位上限面板：手机上改为纵向堆叠 */
  .postlimit-group { flex-direction: column; align-items: stretch; gap: 6px; }
  .postlimit-groupname { min-width: 0; }
  .postlimit-items { gap: 6px; }
  .postlimit-item { flex: 1 1 46%; justify-content: space-between; }
  .postlimit-item input { width: 44px; }

  .grouplimit-item { min-width: 0; }
  .onduty-row { grid-template-columns: 62px 1fr 1fr; gap: 6px; }

  .toast { bottom: 20px; font-size: 12.5px; padding: 9px 16px; max-width: 92vw; }
}
