:root {
  --navy: #12335f;
  --navy-2: #1e4f8f;
  --navy-3: #2a6ab5;
  --gold: #c9a227;
  --gold-soft: #f5edcf;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e3e8f0;
  --text: #33415c;
  --muted: #8a94a6;
  --ok: #17a673;
  --warn: #e8a33d;
  --err: #d9534f;
  --info: #3d7eff;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(16, 42, 80, .07);
}

* { box-sizing: border-box; }

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

a { color: var(--navy-2); }

/* ============ 布局 ============ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: linear-gradient(180deg, #0f2b50 0%, #12335f 100%);
  color: #cfd9e8;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand h1 { margin: 0; font-size: 15px; color: #fff; font-weight: 700; letter-spacing: .3px; }
.brand .sub { font-size: 11px; color: var(--gold); letter-spacing: 2.5px; margin-top: 4px; }

.nav { padding: 12px 10px; flex: 1; }
.nav-group { font-size: 11px; color: #6b83a3; padding: 14px 12px 6px; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: 7px; cursor: pointer;
  color: #cfd9e8; font-size: 13.5px; margin-bottom: 2px;
  transition: all .15s;
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(201,162,39,.16); color: #fff; box-shadow: inset 2px 0 0 var(--gold); }
.nav-item .ico { width: 18px; text-align: center; font-size: 15px; }
.nav-item .badge {
  margin-left: auto; background: var(--err); color: #fff;
  font-size: 10.5px; padding: 1px 6px; border-radius: 9px; font-weight: 700;
}

.sidebar-foot { padding: 14px 18px; font-size: 11px; color: #6b83a3; border-top: 1px solid rgba(255,255,255,.08); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
.dot.ok { background: #2ecc71; } .dot.off { background: #7a8798; } .dot.err { background: #e74c3c; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 14px 26px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { margin: 0; font-size: 17px; color: var(--navy); font-weight: 700; }
.topbar .desc { font-size: 12.5px; color: var(--muted); }
.topbar .spacer { flex: 1; }

.content { padding: 22px 26px 60px; flex: 1; }

/* ============ 组件 ============ */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; }
.card > h3 { margin: 0 0 4px; font-size: 15px; color: var(--navy); }
.card > .hint { font-size: 12.5px; color: var(--muted); margin-bottom: 16px; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 17px 19px; }
.stat .label { font-size: 12.5px; color: var(--muted); }
.stat .value { font-size: 27px; font-weight: 700; color: var(--navy); line-height: 1.25; margin-top: 3px; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.stat.gold .value { color: var(--gold); }
.stat.ok .value { color: var(--ok); }
.stat.err .value { color: var(--err); }

button, .btn {
  font-family: inherit; font-size: 13px; padding: 7px 15px; border-radius: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  cursor: pointer; transition: all .15s; font-weight: 500;
}
button:hover, .btn:hover { border-color: var(--navy-3); color: var(--navy-2); }
button.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
button.primary:hover { background: var(--navy-2); color: #fff; }
button.gold { background: var(--gold); border-color: var(--gold); color: #3a2f00; font-weight: 700; }
button.gold:hover { background: #d8b13a; }
button.danger { color: var(--err); border-color: #f2c9c8; }
button.danger:hover { background: #fdf2f2; border-color: var(--err); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.sm { padding: 4px 10px; font-size: 12px; }

input, select, textarea {
  font-family: inherit; font-size: 13px; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: 6px; width: 100%;
  background: #fff; color: var(--text); transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-3); }
textarea { resize: vertical; min-height: 76px; line-height: 1.65; font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12.5px; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
label.field .help { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { flex-shrink: 0; }
.row .grow { flex: 1; min-width: 140px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 9px 10px; border-bottom: 2px solid var(--line); color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid #f0f3f8; vertical-align: top; }
tr:hover td { background: #fafbfd; }

.tag {
  display: inline-block; padding: 1.5px 8px; border-radius: 10px;
  font-size: 11.5px; background: #eef2f8; color: #5a6b85; margin: 1px 3px 1px 0; white-space: nowrap;
}
.tag.ok { background: #e6f7f0; color: #0f7a55; }
.tag.warn { background: #fdf4e3; color: #a06b12; }
.tag.err { background: #fdeceb; color: #b93f3b; }
.tag.info { background: #e8f0fe; color: #2a5db0; }
.tag.gold { background: var(--gold-soft); color: #8a6d0b; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 9px; border-radius: 20px; background: #eef2f8; color: #5a6b85; }
.pill.ok { background: #e6f7f0; color: #0f7a55; }
.pill.err { background: #fdeceb; color: #b93f3b; }
.pill.warn { background: #fdf4e3; color: #a06b12; }
.pill.info { background: #e8f0fe; color: #2a5db0; }
.pill.run { background: #e8f0fe; color: #2a5db0; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12px; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; } .mt-s { margin-top: 7px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.bar { height: 8px; background: #eef2f8; border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--navy-2), var(--navy-3)); border-radius: 4px; }
.bar.gold > i { background: linear-gradient(90deg, #d8b13a, var(--gold)); }

/* 待确认高亮 */
.confirm-box { border: 1px solid #f0dda6; background: linear-gradient(180deg, #fffdf5, #fff); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.confirm-box h3 { margin: 0 0 4px; color: #8a6d0b; font-size: 15px; }
.confirm-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px dashed #f0e3c0; }
.confirm-item:last-child { border-bottom: none; }
.confirm-item .info { flex: 1; min-width: 0; }
.confirm-item .name { font-weight: 600; color: var(--navy); }
.confirm-item .meta { font-size: 12px; color: var(--muted); }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(16,32,56,.42); display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 720px; box-shadow: 0 20px 60px rgba(0,0,0,.22); }
.modal.wide { max-width: 960px; }
.modal-head { padding: 18px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; position: sticky; top: 0; background: #fff; border-radius: 12px 12px 0 0; z-index: 1; }
.modal-head h3 { margin: 0; font-size: 16px; color: var(--navy); flex: 1; }
.modal-body { padding: 22px 24px; max-height: 68vh; overflow-y: auto; }
.modal-foot { padding: 14px 24px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

/* 提示 */
#toasts { position: fixed; top: 18px; right: 18px; z-index: 300; display: flex; flex-direction: column; gap: 9px; }
.toast { background: #fff; border-left: 4px solid var(--navy-3); padding: 12px 18px; border-radius: 7px; box-shadow: 0 6px 22px rgba(16,42,80,.16); font-size: 13px; min-width: 240px; max-width: 420px; animation: slideIn .22s ease; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 日志 */
.logline { font-family: ui-monospace, Consolas, monospace; font-size: 12px; padding: 4px 8px; border-bottom: 1px solid #f2f5fa; display: flex; gap: 10px; }
.logline .t { color: var(--muted); flex-shrink: 0; }
.logline.err { background: #fdf4f4; }
.logline.warn { background: #fffbf0; }

/* 员工卡 */
.emp-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; border-top: 3px solid var(--navy-2); }
.emp-card.off { opacity: .62; border-top-color: var(--muted); }
/**
 * 当天 0 任务的员工：灰化 + 待命中
 *
 * 「员工是不是闲着」是主人最关心的问题之一，所以让它在卡片墙里一眼可辨 ——
 * 不做区分的话，一个 0 会淹没在一堆数字里，看不出谁今天没干活。
 */
.emp-card.idle { border-top-color: #cbd5e0; background: #fafbfc; }
.emp-card.idle .head .avatar { background: #e2e8f0; filter: grayscale(1); opacity: .75; }
.emp-card.idle .title .n { color: #718096; }
.emp-card.idle .desc { opacity: .8; }
.emp-card .head { display: flex; align-items: center; gap: 11px; margin-bottom: 10px; }
.emp-card .avatar { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, var(--navy), var(--navy-3)); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.emp-card .title { flex: 1; min-width: 0; }
.emp-card .title .n { font-weight: 700; color: var(--navy); font-size: 14.5px; }
.emp-card .title .d { font-size: 12px; color: var(--muted); }
.emp-card .desc { font-size: 12.5px; color: #5a6b85; line-height: 1.7; min-height: 42px; }

/* 开关 */
.switch { position: relative; width: 42px; height: 23px; flex-shrink: 0; cursor: pointer; }
.switch input { display: none; }
.switch i { position: absolute; inset: 0; background: #ccd4e0; border-radius: 12px; transition: .2s; }
.switch i::after { content: ''; position: absolute; width: 17px; height: 17px; background: #fff; border-radius: 50%; top: 3px; left: 3px; transition: .2s; }
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(19px); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 8px 15px; cursor: pointer; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; user-select: none; }
.tab:hover { color: var(--navy-2); }
.tab.active { color: var(--navy); border-bottom-color: var(--gold); font-weight: 600; }

pre.md { background: #fafbfd; border: 1px solid var(--line); border-radius: 8px; padding: 16px; font-size: 12.5px; line-height: 1.8; white-space: pre-wrap; word-break: break-word; max-height: 480px; overflow-y: auto; font-family: ui-monospace, Consolas, monospace; }

.kv { display: grid; grid-template-columns: 132px 1fr; gap: 7px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.loading { display: inline-block; width: 13px; height: 13px; border: 2px solid #dbe2ec; border-top-color: var(--navy-3); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: -232px; z-index: 50; transition: left .22s; }
  .sidebar.open { left: 0; }
  .content { padding: 16px; }
  .kv { grid-template-columns: 100px 1fr; }
}

/* 表单校验反馈 */
.field input.invalid,
.field select.invalid,
.field textarea.invalid {
  border-color: var(--err, #d9534f) !important;
  background: #fff8f8;
}
.field-error {
  color: var(--err, #d9534f);
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.5;
}
