:root {
  --bg: #f5f6f8;
  --surface: #fff;
  --border: #e2e5ea;
  --text: #1f2328;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  /* 排班表的斑马纹：一行黄一行白、一列蓝一列白，交叉处叠成浅绿，方便横竖对位 */
  --row-stripe: rgba(250, 204, 21, 0.18);
  --col-stripe: rgba(59, 130, 246, 0.10);
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* ---- 顶栏 ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 28px;
  height: 52px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { padding: 6px 14px; border-radius: 6px; color: var(--muted); text-decoration: none; }
.topbar nav a:hover { background: var(--bg); color: var(--text); }
.topbar nav a.active { background: #eef2ff; color: var(--primary); font-weight: 600; }
body.logged-out .topbar nav { display: none; }

main { max-width: 1100px; margin: 0 auto; padding: 20px; }
main.wide { max-width: none; }

/* ---- 通用控件 ---- */
button, .button {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 6px;
  font: inherit; color: var(--text); background: var(--surface);
  text-decoration: none; cursor: pointer;
}
button:hover, .button:hover { border-color: #c2c8d1; }
button.primary { color: #fff; background: var(--primary); border-color: var(--primary); }
button.primary:hover { background: var(--primary-hover); }
button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); }
button:disabled, button:disabled:hover { opacity: 0.45; border-color: var(--border); cursor: not-allowed; }
button.icon { padding: 0 6px; border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.tabs { display: flex; gap: 2px; padding: 3px; border-radius: 8px; background: #e8ebf0; }
.tabs a { padding: 5px 16px; border-radius: 6px; color: var(--muted); text-decoration: none; }
.tabs a.active { color: var(--text); background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 14px; }
.filters .label { font-size: 13px; color: var(--muted); }
.filters .chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 12px;
  border: 1px solid var(--border); border-radius: 99px; background: var(--surface);
  cursor: pointer; user-select: none;
}
.filters .chip:has(input:not(:checked)) { color: var(--muted); background: transparent; }

.tag { padding: 1px 8px; border-radius: 99px; font-size: 12px; white-space: nowrap; color: #3730a3; background: #eef2ff; }
.tag.muted { color: var(--muted); background: #f0f1f3; }
.tag.ok { color: #166534; background: #dcfce7; }
.empty { padding: 48px 0; text-align: center; color: var(--muted); }
.hint { margin: -6px 0 12px; font-size: 12px; color: var(--muted); }

/* ---- 卡片列表 ---- */
.cards { display: grid; gap: 10px; }
.cards.small { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.card { padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: #b7c1cf; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06); }
.card.off { opacity: 0.6; }
.card .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card .big { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card .preview {
  margin: 6px 0 0; color: #374151; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .meta { margin-top: 6px; font-size: 12px; color: var(--muted); }
.card .actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---- 弹窗与表单 ---- */
dialog.dialog {
  width: min(640px, calc(100vw - 32px)); padding: 0;
  border: 0; border-radius: 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
dialog.dialog::backdrop { background: rgba(15, 23, 42, 0.35); }
.dialog header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.dialog h2 { margin: 0; font-size: 16px; }
.dialog .body { max-height: calc(100vh - 210px); padding: 16px 20px; overflow: auto; }
.dialog footer { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }
.dialog footer .spacer { flex: 1; }

.form { display: grid; gap: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* align-content: start —— 并排的两栏被撑成一样高时，输入框别跟着被拉高 */
.field { display: grid; gap: 4px; align-content: start; }
.field .label { display: flex; align-items: center; font-size: 13px; font-weight: 600; }
.field small { font-size: 12px; color: var(--muted); }

/* 标题右边的「?」和它浮出的说明 */
.tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-left: 6px; border: 1px solid #c2c8d1; border-radius: 50%;
  font-size: 11px; font-weight: 700; line-height: 1; color: var(--muted);
  cursor: help; user-select: none;
}
.tip:hover, .tip:focus { color: var(--primary); border-color: var(--primary); outline: none; }
.tip-bubble {
  position: fixed; z-index: 1000; max-width: 260px; padding: 6px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 400; line-height: 1.5; color: #fff; background: #1f2937;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18); pointer-events: none;
}
.field input, .field textarea {
  width: 100%; padding: 7px 10px;
  border: 1px solid #cdd3db; border-radius: 6px;
  font: inherit; background-color: #fff;
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
.field.bad input, .field.bad textarea { border-color: var(--bad); background-color: var(--bad-bg); }
.field.bad .label { color: var(--bad); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }

/* 任务的「重复」：每天 / 每周 / 每月单选。每周是一排 7 个方块，铺满整行，点一下选中；
   每月是 jSuites 的多选下拉 */
.field .repeat { display: flex; gap: 18px; }
.field .repeat label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.field .repeat input { width: auto; margin: 0; }
.field .days { margin-top: 4px; }
.field .week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.field .week label {
  position: relative; display: flex; align-items: center; justify-content: center; height: 30px;
  border: 1px solid #cdd3db; border-radius: 6px; cursor: pointer; user-select: none;
}
.field .week input { position: absolute; width: 1px; height: 1px; padding: 0; opacity: 0; }
.field .week label:has(input:checked) { color: #fff; background: var(--primary); border-color: var(--primary); }
.field .week label:has(input:focus-visible) { outline: 2px solid #bfdbfe; }
/* 下拉整行宽，框和别的输入框一样高（右边给箭头留的 30px 是 jSuites 的 !important） */
.field .jdropdown { display: block; }
.field .jdropdown-header { padding: 7px 10px; }
/* jSuites 默认鼠标移上去也是蓝底，和「已选中」分不清：没选中的只给浅灰 */
.field .jdropdown-default .jdropdown-item:hover:not(.jdropdown-selected) { color: #000; background-color: #f0f1f3; }
.registration { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.images { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.images figure {
  position: relative; width: 96px; height: 96px; margin: 0;
  border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: #f8fafc;
}
.images img { width: 100%; height: 100%; object-fit: cover; }
.images .remove {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; padding: 0;
  justify-content: center; font-size: 15px; color: #fff; background: rgba(0, 0, 0, 0.55); border-radius: 99px;
}
.images .add { width: 96px; height: 96px; justify-content: center; border-style: dashed; color: var(--muted); }

/* ---- 提示条 ---- */
#toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 100; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 8px;
  color: #fff; background: #15803d; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
#toast.error { background: var(--danger); }

/* ---- 登录 ---- */
.login {
  display: grid; gap: 12px; max-width: 320px; margin: 12vh auto; padding: 28px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.login h1 { margin: 0 0 4px; font-size: 18px; text-align: center; }
.login input { padding: 8px 10px; border: 1px solid #cdd3db; border-radius: 6px; font: inherit; }
.login button { justify-content: center; }

/* ---- 排班表格 ---- */
.month-nav { display: flex; align-items: center; gap: 12px; }
.month-nav strong { min-width: 110px; font-size: 16px; text-align: center; }
.grid-holder { background: var(--surface); }
.grid-holder .jss_worksheet td.readonly { color: #4b5563; }
/* 列 = td 的序号：1 是行号，2 员工ID，3 姓名，4 起是 1 号、2 号……所以奇数序号从 5 起 = 双号日 */
.grid-holder .jss_worksheet > tbody > tr:nth-child(even) > td:not(:first-child) {
  background-image: linear-gradient(var(--row-stripe), var(--row-stripe));
}
.grid-holder .jss_worksheet > thead > tr > td:nth-child(odd):nth-child(n+5),
.grid-holder .jss_worksheet > tbody > tr > td:nth-child(odd):nth-child(n+5) {
  background-image: linear-gradient(var(--col-stripe), var(--col-stripe));
}
.grid-holder .jss_worksheet > tbody > tr:nth-child(even) > td:nth-child(odd):nth-child(n+5) {
  background-image: linear-gradient(var(--row-stripe), var(--row-stripe)),
                    linear-gradient(var(--col-stripe), var(--col-stripe));
}
.grid-holder .jss_worksheet > tbody > tr > td.bad {
  background: var(--bad-bg) !important; box-shadow: inset 0 0 0 2px var(--bad);
}
