:root {
  --navy: #0d2137;
  --navy-2: #16324f;
  --primary: #1668dc;
  --primary-dark: #1257ba;
  --primary-soft: #e8f1ff;
  --bg: #f1f4f9;
  --card: #ffffff;
  --text: #1d2b3a;
  --muted: #78889b;
  --line: #e4eaf2;
  --green: #0f9960;
  --green-soft: #e6f6ee;
  --red: #d93b3b;
  --red-soft: #fdeaea;
  --amber: #c9761a;
  --amber-soft: #fdf3e4;
  --purple: #6b4fd8;
  --shadow: 0 1px 2px rgba(16, 40, 74, .06), 0 4px 14px rgba(16, 40, 74, .05);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cfd8e3; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 登录 ============ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 15% 10%, #1d4d7c 0%, transparent 55%),
              radial-gradient(900px 500px at 90% 90%, #14385c 0%, transparent 50%),
              linear-gradient(135deg, #0b1c2e 0%, #123153 55%, #0e2540 100%);
  padding: 24px;
}
.login-card {
  width: 940px; max-width: 100%; background: #fff; border-radius: 16px; overflow: hidden;
  display: grid; grid-template-columns: 1.05fr .95fr; box-shadow: 0 24px 60px rgba(3, 15, 30, .45);
}
.login-left { padding: 46px 42px; color: #fff; background: linear-gradient(160deg, #123a61, #0d2137 70%); position: relative; }
.login-left::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 34px 34px; pointer-events: none;
}
.login-left h1 { font-size: 25px; margin: 0 0 10px; letter-spacing: .5px; }
.login-left p.sub { color: #a9c4de; margin: 0 0 36px; font-size: 13px; line-height: 1.9; }
.login-feat { display: flex; gap: 12px; margin-bottom: 18px; align-items: flex-start; position: relative; z-index: 2; }
.login-feat .dot { width: 26px; height: 26px; border-radius: 8px; background: rgba(255,255,255,.1); display: grid; place-items: center; flex: 0 0 26px; }
.login-feat b { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 3px; }
.login-feat span { font-size: 12px; color: #96b3cf; line-height: 1.6; }
.login-right { padding: 54px 48px; }
.login-right h2 { margin: 0 0 6px; font-size: 20px; }
.login-right .hint { color: var(--muted); font-size: 12.5px; margin-bottom: 28px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; color: #526072; margin-bottom: 7px; font-weight: 500; }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid #d8e0ea; border-radius: 8px;
  background: #fff; font-size: 13.5px; color: var(--text); outline: none; transition: .15s;
}
.textarea { height: auto; padding: 8px 11px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,104,220,.12); }
.login-btn {
  width: 100%; height: 42px; border: 0; border-radius: 8px; background: var(--primary); color: #fff;
  font-size: 14.5px; font-weight: 600; cursor: pointer; margin-top: 6px; transition: .15s;
}
.login-btn:hover { background: var(--primary-dark); }
.login-btn:disabled { opacity: .6; cursor: default; }
.demo-accounts { margin-top: 26px; border-top: 1px dashed var(--line); padding-top: 16px; }
.demo-accounts .t { font-size: 12px; color: var(--muted); margin-bottom: 9px; }
.demo-accounts .acc { display: flex; gap: 8px; flex-wrap: wrap; }
.demo-accounts .acc button {
  border: 1px solid #dbe4ef; background: #f7faff; color: #33475f; border-radius: 20px;
  padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.demo-accounts .acc button:hover { border-color: var(--primary); color: var(--primary); }

/* ============ 框架 ============ */
.app { display: none; min-height: 100vh; }
.app.on { display: flex; }
.sidebar {
  width: 228px; flex: 0 0 228px; background: linear-gradient(180deg, #0f2a45, #0b1f35);
  color: #c7d8ea; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 18px 20px 16px; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #2b8cf0, #1668dc); display: grid; place-items: center; flex: 0 0 34px; }
.brand b { color: #fff; font-size: 14px; display: block; line-height: 1.25; font-weight: 600; }
.brand .co { font-size: 12.5px; color: #d5e4f2; display: block; line-height: 1.5; margin-top: 1px; }
.brand span { font-size: 10.5px; color: #7b97b3; letter-spacing: .4px; }
.nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav .group { font-size: 10.5px; color: #5d7d9c; letter-spacing: 1.5px; padding: 14px 12px 7px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #b6cbdf;
  font-size: 13.5px; margin-bottom: 2px; cursor: pointer; transition: .13s; position: relative;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.on { background: linear-gradient(90deg, rgba(43,140,240,.28), rgba(43,140,240,.08)); color: #fff; font-weight: 500; }
.nav a.on::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #2b8cf0; }
.nav a svg { width: 16px; height: 16px; flex: 0 0 16px; opacity: .85; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.07); font-size: 11.5px; color: #68859f; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center;
  padding: 0 22px; gap: 16px; position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 16px; margin: 0; font-weight: 600; }
.topbar .crumb { color: var(--muted); font-size: 12px; }
.topbar .spacer { flex: 1; }
.topbar .who { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 12.5px; font-weight: 600; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.role-tag { font-size: 11px; background: #eef3fa; color: #5b7186; border-radius: 4px; padding: 2px 7px; }
.content { padding: 20px 22px 42px; flex: 1; }

/* ============ 通用 ============ */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid #eef2f7; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-h h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-h .sub { color: var(--muted); font-size: 12px; }
.card-h .spacer { flex: 1; }
.card-b { padding: 16px 18px; }
.card-b.tight { padding: 8px 6px; }

.btn {
  height: 34px; padding: 0 14px; border-radius: 7px; border: 1px solid #d8e0ea; background: #fff; color: #35485c;
  font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: .14s; white-space: nowrap;
}
.btn:hover { border-color: #b9c7d8; background: #fafcff; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: #f0c4c4; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt20 { margin-top: 20px; }
.hidden { display: none !important; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 130px; height: 34px; }
.toolbar .search { width: 220px; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; padding: 2px 8px; border-radius: 20px; line-height: 1.6; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--primary-soft); color: var(--primary); }
.badge.gray { background: #f0f3f7; color: #6c7d8f; }
.badge.purple { background: #efeafd; color: var(--purple); }

table.tb { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.tb th {
  text-align: left; font-weight: 600; color: #5c6f83; background: #f7f9fc; padding: 10px 12px;
  border-bottom: 1px solid var(--line); font-size: 12.5px; white-space: nowrap;
}
table.tb td { padding: 10px 12px; border-bottom: 1px solid #f0f4f9; vertical-align: middle; }
table.tb tbody tr:hover td { background: #f9fbfe; }
table.tb tbody tr:last-child td { border-bottom: 0; }
table.tb td.num, table.tb th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tb-wrap { overflow: auto; }
.tb-wrap.sticky th { position: sticky; top: 0; z-index: 2; }
.clickable { cursor: pointer; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { background: #fff; border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); border: 1px solid #eef2f7; position: relative; overflow: hidden; }
.kpi .k-label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .k-val { font-size: 27px; font-weight: 650; letter-spacing: -.4px; margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
.kpi .k-val small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi .k-sub { font-size: 11.5px; color: var(--muted); }
.kpi .k-icon { position: absolute; right: 14px; top: 14px; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; }
.kpi.blue .k-icon { background: var(--primary-soft); color: var(--primary); }
.kpi.green .k-icon { background: var(--green-soft); color: var(--green); }
.kpi.amber .k-icon { background: var(--amber-soft); color: var(--amber); }
.kpi.purple .k-icon { background: #efeafd; color: var(--purple); }

.grid2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; }
.grid2.eq { grid-template-columns: 1fr 1fr; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); font-size: 13px; }
.empty .ico { font-size: 26px; opacity: .35; margin-bottom: 10px; }

/* ============ 弹窗 ============ */
.mask { position: fixed; inset: 0; background: rgba(10, 24, 40, .45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px; animation: fade .12s; }
@keyframes fade { from { opacity: 0 } }
.modal { background: #fff; border-radius: 12px; width: 560px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(6, 18, 34, .3); animation: pop .16s ease-out; }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: .6 } }
.modal.wide { width: 880px; }
.modal.xwide { width: 1080px; }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-h h3 { margin: 0; font-size: 15px; }
.modal-h .x { margin-left: auto; border: 0; background: none; font-size: 20px; color: #9aa9ba; cursor: pointer; line-height: 1; padding: 0 4px; }
.modal-b { padding: 18px 20px; overflow: auto; }
.modal-f { padding: 13px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; background: #fbfcfe; border-radius: 0 0 12px 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: block; font-size: 12.5px; color: #5a6b7e; margin-bottom: 6px; }

/* ============ 提示 ============ */
#toasts { position: fixed; top: 16px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #fff; border-left: 3px solid var(--primary); box-shadow: 0 8px 24px rgba(15, 40, 70, .16);
  border-radius: 8px; padding: 11px 16px; font-size: 13px; min-width: 220px; max-width: 380px; animation: slidein .18s;
}
.toast.err { border-color: var(--red); }
.toast.ok { border-color: var(--green); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0 } }

/* ============ 打卡 ============ */
.punch-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; align-items: start; }
.cam-box { background: #0b1a2b; border-radius: 12px; overflow: hidden; position: relative; aspect-ratio: 4 / 3; display: grid; place-items: center; }
.cam-box video, .cam-box canvas, .cam-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-box .ph { color: #5f7c98; text-align: center; font-size: 13px; padding: 20px; }
.cam-badge { position: absolute; top: 12px; left: 12px; background: rgba(0,0,0,.45); color: #fff; font-size: 11.5px; padding: 4px 10px; border-radius: 20px; backdrop-filter: blur(4px); }
.cam-clock { position: absolute; bottom: 12px; right: 12px; color: #fff; font-size: 13px; font-variant-numeric: tabular-nums; background: rgba(0,0,0,.42); padding: 4px 10px; border-radius: 8px; }
.face-frame { position: absolute; inset: 16% 27%; border: 2px dashed rgba(90, 190, 255, .6); border-radius: 50% / 42%; pointer-events: none; }
.punch-list { max-height: 512px; overflow: auto; }
.punch-item { display: flex; gap: 10px; padding: 9px 14px; border-bottom: 1px solid #f2f5f9; align-items: center; }
.punch-item .t { font-variant-numeric: tabular-nums; font-size: 12.5px; color: #526072; width: 62px; }
.punch-item img.thumb { width: 34px; height: 34px; border-radius: 7px; object-fit: cover; }
.punch-item .nm { font-size: 13px; }
.punch-item .meta { font-size: 11.5px; color: var(--muted); }

/* ============ 考勤网格 ============ */
.att-wrap { overflow: auto; max-height: calc(100vh - 300px); border-radius: 8px; border: 1px solid var(--line); }
.att-table { border-collapse: separate; border-spacing: 0; font-size: 12px; width: max-content; min-width: 100%; }
.att-table th, .att-table td { border-right: 1px solid #eef2f7; border-bottom: 1px solid #eef2f7; padding: 0; text-align: center; }
.att-table th { background: #f7f9fc; font-weight: 600; color: #5c6f83; height: 38px; position: sticky; top: 0; z-index: 3; }
.att-table .sticky-l { position: sticky; left: 0; background: #fff; z-index: 2; text-align: left; padding: 0 10px; min-width: 150px; font-size: 12.5px; }
.att-table th.sticky-l { z-index: 4; background: #f7f9fc; }
.att-table .sticky-r { position: sticky; right: 0; background: #fff; z-index: 2; min-width: 92px; }
.att-table th.sticky-r { background: #f7f9fc; z-index: 4; }
.att-table td.sticky-l, .att-table td.sticky-r { box-shadow: -6px 0 8px -8px rgba(0,0,0,.14); }
.att-cell { width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; position: relative; font-size: 11px; }
.att-cell:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
.att-cell.s-normal { background: #e9f6ee; color: #0b7a4b; }
.att-cell.s-late { background: #fdf3e2; color: #a86412; }
.att-cell.s-early { background: #fdf0e6; color: #b0632a; }
.att-cell.s-miss { background: #fdecec; color: #c03535; }
.att-cell.s-abs { background: #f6e9e9; color: #a33; }
.att-cell.s-rest { background: #f4f6f9; color: #9aa9ba; }
.att-cell.s-leave { background: #eaf0fd; color: #3457a8; }
.att-cell .dot { width: 6px; height: 6px; border-radius: 50%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: #5c6f83; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

/* ============ 图标统计 ============ */
.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 70px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-track { height: 8px; background: #f0f4f9; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, #4b9bf5, #1668dc); transition: width .5s; }
.bar-fill.warn { background: linear-gradient(90deg, #f0b04c, #d98a1e); }

.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert { display: flex; gap: 9px; align-items: flex-start; padding: 10px 13px; border-radius: 8px; font-size: 12.5px; line-height: 1.6; }
.alert.danger { background: var(--red-soft); color: #a92f2f; }
.alert.warn { background: var(--amber-soft); color: #96601a; }
.alert.info { background: #eef4fd; color: #2c5c9e; }
.alert .ico { flex: 0 0 16px; margin-top: 1px; }

.chart-wrap { width: 100%; }
.chart-svg { width: 100%; height: auto; display: block; }

.file-drop {
  border: 2px dashed #cbd8e6; border-radius: 10px; padding: 28px; text-align: center; cursor: pointer;
  transition: .15s; background: #fbfdff;
}
.file-drop:hover, .file-drop.over { border-color: var(--primary); background: #f4f9ff; }
.file-drop .big { font-size: 14px; margin-bottom: 6px; font-weight: 500; }
.file-drop .small { font-size: 12px; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button {
  border: 0; background: none; padding: 9px 14px; font-size: 13.5px; color: #64748b; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.on { color: var(--primary); border-color: var(--primary); font-weight: 500; }

.person-head { display: flex; gap: 16px; align-items: center; }
.person-head .ph-avatar { width: 64px; height: 64px; border-radius: 12px; background: var(--primary-soft); display: grid; place-items: center; font-size: 22px; color: var(--primary); font-weight: 600; overflow: hidden; }
.person-head .ph-avatar img { width: 100%; height: 100%; object-fit: cover; }
.person-head .ph-name { font-size: 18px; font-weight: 600; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 9px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }

.section-title { font-size: 13px; font-weight: 600; color: #33475f; margin: 18px 0 10px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 3px; height: 13px; background: var(--primary); border-radius: 2px; }

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid2, .grid2.eq, .grid3 { grid-template-columns: 1fr; }
  .punch-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { position: fixed; z-index: 60; transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: none; }
  .content { padding: 14px; }
  .kpis { grid-template-columns: 1fr; }
}

/* 电子围栏 · 开关 */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #c9d3e0; border-radius: 999px; transition: .18s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .18s; box-shadow: 0 1px 3px rgba(16,32,64,.25); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:disabled + span { opacity: .5; cursor: not-allowed; }
