:root{
  --bg:#f3f5f8; --card:#fff; --ink:#1f2733; --muted:#8a94a6;
  --brand:#2e7d5b; --brand2:#1f8fd6; --line:#e6eaf0;
  --rest:#9aa3ad; --sick:#e0584f; --annual:#9b3fc4; --comp:#e08a1e; --off:#0f9aa8;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0;background:var(--bg);color:var(--ink);
  font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;
  font-size:15px}
.screen{min-height:100vh}
.hidden{display:none !important}

/* 登录 */
#login{display:flex;align-items:center;justify-content:center;min-height:100vh;
  background:linear-gradient(160deg,#2e7d5b,#1f8fd6)}
.login-card{width:86%;max-width:340px;background:#fff;border-radius:18px;padding:30px 24px;
  box-shadow:0 10px 40px rgba(0,0,0,.18)}
body.is-mobile .login-card{padding:22px 18px;border-radius:14px}
.brand{font-size:26px;font-weight:800;text-align:center}
.brand-sub{text-align:center;color:var(--muted);margin:6px 0 22px;font-size:13px}
.login-card input{width:100%;padding:13px 14px;margin-bottom:12px;border:1px solid var(--line);
  border-radius:11px;font-size:15px;outline:none;background:#fafbfc}
.login-card input:focus{border-color:var(--brand)}
.login-card button{width:100%;padding:13px;border:none;border-radius:11px;background:var(--brand);
  color:#fff;font-size:16px;font-weight:700;cursor:pointer}
.hint{margin-top:14px;font-size:12px;color:var(--muted);text-align:center;line-height:1.6}
.msg{color:var(--sick);font-size:13px;text-align:center;min-height:18px;margin-top:6px}
.msg.inline{display:inline-block;margin-left:8px}

/* 顶栏 */
.topbar{display:flex;justify-content:space-between;align-items:center;padding:14px 16px;
  background:#fff;border-bottom:1px solid var(--line);position:sticky;top:0;z-index:5}
.who{font-weight:700}
.role-tag{font-size:11px;background:var(--brand);color:#fff;border-radius:6px;padding:2px 7px;margin-left:7px}
.link{background:none;border:none;color:var(--brand2);font-size:14px;cursor:pointer}

/* tabs */
.tabs{display:flex;background:#fff;border-bottom:1px solid var(--line);position:sticky;top:53px;z-index:4}
.tab{flex:1;padding:12px 4px;border:none;background:none;color:var(--muted);font-size:14px;
  border-bottom:2px solid transparent;cursor:pointer}
.tab.active{color:var(--brand);border-bottom-color:var(--brand);font-weight:700}
.tab-pane{display:none;padding:14px}
.tab-pane.active{display:block}

/* 月份条 */
.month-bar{display:flex;align-items:center;justify-content:center;gap:18px;margin-bottom:12px}
.month-bar button{border:1px solid var(--line);background:#fff;border-radius:9px;width:34px;height:34px;
  font-size:18px;cursor:pointer}
#monthLabel,#mLabel{font-weight:700;min-width:96px;text-align:center}
.dot{width:9px;height:9px;border-radius:50%;background:#ccc;transition:.3s}
.dot.live{background:#2ecc71;box-shadow:0 0 0 4px rgba(46,204,113,.18)}

/* 日历 */
.calendar{display:grid;grid-template-columns:repeat(7,1fr);gap:7px}
.cal-cell{background:var(--card);border-radius:11px;padding:7px 4px;text-align:center;
  border:1px solid var(--line);min-height:62px;display:flex;flex-direction:column;justify-content:center}
.cal-cell .d{font-size:12px;color:var(--muted)}
.cal-cell .sh{font-weight:700;font-size:14px;margin-top:3px}
.cal-cell .tm{font-size:10px;color:var(--muted)}
.cal-cell.rest{background:#f1f3f6}
.cal-cell.rest .sh{color:var(--rest)}
.cal-cell.sick{background:#fdecea}.cal-cell.sick .sh{color:var(--sick)}
.cal-cell.annual{background:#f6ecfb}.cal-cell.annual .sh{color:var(--annual)}
.cal-cell.comp{background:#fdf2e3}.cal-cell.comp .sh{color:var(--comp)}
.cal-cell.off{background:#e6f7f9}.cal-cell.off .sh{color:var(--off)}
.cal-cell.na{opacity:.5}
.cal-cell.today{outline:2px solid var(--brand2)}

/* 卡片 */
.cards{display:flex;flex-direction:column;gap:10px;margin-bottom:16px}
.kpi{background:var(--card);border-radius:14px;padding:14px 16px;border:1px solid var(--line);
  display:flex;justify-content:space-between;align-items:center}
.kpi .v{font-size:22px;font-weight:800}
.kpi .v small{font-size:13px;color:var(--muted);font-weight:500}
.kpi .l{color:var(--muted);font-size:13px}
.kpi.green .v{color:var(--brand)}
.kpi.blue .v{color:var(--brand2)}
.kpi.purple .v{color:var(--annual)}
.section-title{font-size:13px;color:var(--muted);margin:6px 2px}
.dist{display:flex;flex-wrap:wrap;gap:8px}
.dist .chip{background:#fff;border:1px solid var(--line);border-radius:20px;padding:6px 12px;font-size:13px}
.dist .chip b{color:var(--brand)}

/* 管理网格 */
.toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin-bottom:10px}
.btn{border:none;background:var(--brand);color:#fff;padding:9px 13px;border-radius:10px;font-size:13px;cursor:pointer}
.btn:active{transform:scale(.97)}
.grid-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
.grid{display:grid;border:1px solid var(--line);border-radius:10px;overflow:hidden;min-width:640px}
.grid .gh,.grid .rh{background:#eef1f5;font-size:12px;padding:6px 4px;text-align:center}
.grid .rh{position:sticky;left:0;background:#eef1f5;z-index:2;text-align:left;padding-left:8px;white-space:nowrap}
.grid .cell{padding:6px 4px;text-align:center;border-top:1px solid var(--line);border-left:1px solid var(--line);
  font-size:12px;cursor:pointer;min-width:30px}
.grid .cell:hover{background:#f0f7f3}
.grid .cell.rest{color:var(--rest)}
.grid .cell.sel{outline:2px solid var(--brand2)}
.grid .cell.ro{cursor:default}
.grid .cell.ro:hover{filter:brightness(.96)}

/* 整体排班外层容器（无边框，仅作布局容器） */
.overview-area{display:block}

/* ===== 整体排班（overview）：首列姓名 + 首行日期 双冻结 ===== */
/* 整个网格是一个 grid + 双向滚动的容器；表头行和姓名列通过 position:sticky 实现冻结 */
.grid-body.overview{
  display:grid;
  overflow:auto;                   /* 双向滚动都靠这一个容器 */
  -webkit-overflow-scrolling:touch;
  max-height:62vh;                 /* 限制纵向高度，超出则内部滚动 */
  border:1px solid var(--line);
  border-radius:10px;
  background:#fff;
  min-width:640px;
}
/* 表头（首行）：top:0 冻结 */
.grid-body.overview > .gh{
  position:sticky;top:0;z-index:3;
  background:#eef1f5;
  padding:7px 4px;text-align:center;font-size:12px;font-weight:600;
  border-bottom:1px solid var(--line);
}
/* 首行最左的"姓名"格：同时 sticky top+left，z-index 最高 */
.grid-body.overview > .head-corner{
  position:sticky;top:0;left:0;z-index:5;
  background:#eef1f5;
  text-align:left;padding-left:10px;
  border-right:1px solid var(--line);
  font-weight:700;
}
/* 姓名列：sticky left:0，z-index 高于普通日期格 */
.grid-body.overview > .row-name{
  position:sticky;left:0;z-index:2;
  background:inherit;             /* 行底色由内联 style 覆盖 */
  text-align:left;padding:7px 4px 7px 10px;
  font-size:12px;font-weight:600;
  white-space:nowrap;
  border-right:1px solid var(--line);
  box-shadow:1px 0 0 rgba(0,0,0,.05);
}
/* 兼容：单元格 border 拆给 cell 自身 */
.grid-body.overview > .cell{
  padding:6px 4px;text-align:center;
  border-top:1px solid var(--line);
  border-left:1px solid var(--line);
  font-size:12px;min-width:30px;cursor:default;
}
.grid-body.overview > .cell.ro:hover{filter:brightness(.96)}
.grid-body.overview > .cell.rest{color:var(--rest)}


/* 年假台账（排班管理 tab） */
.al-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap;background:#fff;
  border:1px solid var(--line);border-radius:12px;padding:10px 12px;margin-bottom:8px}
.al-emp{flex:1;min-width:110px}
.al-name{font-weight:700;font-size:15px}
.al-sub{font-size:11px;color:var(--muted);margin-top:2px}
.al-cell{display:flex;align-items:center;gap:5px;background:#f7f9fb;border-radius:8px;padding:5px 8px}
.al-lab{font-size:11px;color:var(--muted)}
.al-val{font-size:15px;min-width:20px;text-align:center}
.al-btn{width:26px;height:26px;border-radius:7px;border:1px solid var(--line);
  background:#fff;font-size:15px;cursor:pointer;line-height:1;padding:0}
.al-btn:active{background:var(--brand);color:#fff;border-color:var(--brand)}
.al-rem{font-size:13px;color:var(--annual);font-weight:700;min-width:64px;text-align:right}
body.is-mobile .al-row{padding:9px 10px;gap:7px}
body.is-mobile .al-emp{min-width:100%}

/* 弹层 */
.sheet{position:fixed;left:0;right:0;bottom:0;background:#fff;border-radius:18px 18px 0 0;
  box-shadow:0 -8px 30px rgba(0,0,0,.15);padding:16px;z-index:20;animation:up .2s ease}
@keyframes up{from{transform:translateY(100%)}to{transform:translateY(0)}}
.sheet-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;font-weight:700}
.picker{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;margin-bottom:12px}
.picker .opt{padding:11px 4px;border:1px solid var(--line);border-radius:10px;text-align:center;
  font-size:13px;cursor:pointer;background:#fafbfc}
.picker .opt.rest{color:var(--rest)}
.picker .opt.sick{color:var(--sick)}
.picker .opt.sel{background:var(--brand);color:#fff;border-color:var(--brand)}
#editNote{width:100%;padding:11px;border:1px solid var(--line);border-radius:10px;margin-top:4px;font-size:14px}

/* ---------------- 日期表头：周几 + 节假日标注 ---------------- */
.gh.head-date small{display:block;font-size:9px;line-height:1.3;font-weight:500;
  color:#8a94a6;margin-top:1px;white-space:nowrap;overflow:hidden}
.gh.head-date.hol{color:#e0584f;background:#fdeceb}
.gh.head-date.hol small{color:#e0584f;font-weight:700}
.gh.head-date.tiao{color:#b8860b}
.gh.head-date.tiao small{color:#b8860b;font-weight:700}
.hol-text{color:#e0584f!important;font-weight:700}
.tiao-text{color:#b8860b!important;font-weight:700}
#pwSheet input{width:100%;padding:12px;border:1px solid var(--line);border-radius:10px;
  margin-bottom:10px;font-size:15px;outline:none;background:#fafbfc}
#pwSheet input:focus{border-color:var(--brand)}

/* toast */
.toast{position:fixed;bottom:24px;left:50%;transform:translateX(-50%);background:#1f2733;color:#fff;
  padding:11px 18px;border-radius:22px;font-size:14px;z-index:30;box-shadow:0 6px 20px rgba(0,0,0,.25)}

.admin-only{display:none}
body.is-admin .admin-only{display:block}

/* ============================================================
   移动端专属样式 — 仅在 body.is-mobile 下生效
   ============================================================ */
.tabbar{display:none}    /* 桌面下隐藏，由 is-mobile 覆盖显示 */

/* 移动端：紧凑字号、底部 tab 栏、整体排班按日切换 */
body.is-mobile{
  font-size:14px;
}
body.is-mobile .topbar{padding:10px 12px;font-size:13px}
body.is-mobile .tabs{display:none}
body.is-mobile .tabbar{
  display:flex;
  position:fixed;left:0;right:0;bottom:0;z-index:9;
  background:#fff;border-top:1px solid var(--line);
  padding:6px 4px calc(6px + env(safe-area-inset-bottom));
  justify-content:space-around;align-items:center;
  box-shadow:0 -2px 12px rgba(0,0,0,.06);
}
body.is-mobile .tabbar-btn{
  flex:1;display:flex;flex-direction:column;align-items:center;
  background:none;border:none;color:var(--muted);font-size:11px;cursor:pointer;padding:4px 0;
}
body.is-mobile .tabbar-btn .ti{font-size:20px;line-height:1.1;
  font-family:-apple-system,"PingFang SC","Segoe UI Emoji","Apple Color Emoji","Noto Color Emoji",sans-serif}
body.is-mobile .tabbar-btn .tl{margin-top:2px}
body.is-mobile .tabbar-btn.active{color:var(--brand)}
/* 底部 tab 栏会覆盖内容，故主体加底部内边距 */
body.is-mobile main{padding-bottom:64px}
body.is-mobile .tab-pane{padding:12px}
body.is-mobile .month-bar button{width:32px;height:32px}

/* 整体排班：移动端只显示按日切换视图，桌面端显示双冻结网格 */
body.is-mobile .overview-desktop{display:none}
body.is-desktop .overview-mobile{display:none}

/* 移动端按日切换样式 */
body.is-mobile .day-bar{
  display:flex;align-items:center;justify-content:space-between;
  background:#fff;border:1px solid var(--line);border-radius:12px;padding:6px 10px;
  margin-bottom:10px;
}
body.is-mobile .day-bar button{
  background:none;border:none;color:var(--brand2);font-size:24px;
  width:36px;height:36px;cursor:pointer;border-radius:8px;
}
body.is-mobile .day-bar button:active{background:#eaf3fb}
body.is-mobile .day-info{text-align:center;flex:1}
body.is-mobile .day-label{font-weight:700;font-size:16px}
body.is-mobile .day-weekday{font-size:12px;color:var(--muted);margin-top:2px}
body.is-mobile .day-picker{
  width:100%;padding:8px 10px;border:1px solid var(--line);border-radius:9px;
  margin-bottom:10px;font-size:14px;background:#fff;
}
body.is-mobile .day-list{display:flex;flex-direction:column;gap:6px}
body.is-mobile .day-row{
  display:flex;align-items:center;justify-content:space-between;
  padding:10px 12px;border-radius:10px;border:1px solid rgba(0,0,0,.04);
}
body.is-mobile .day-emp .name{font-weight:700;font-size:15px}
body.is-mobile .day-emp .pos{font-size:11px;color:#6f7a8a;margin-top:1px}
body.is-mobile .day-shift{
  font-size:18px;font-weight:800;min-width:48px;text-align:center;
  padding:8px 12px;border-radius:8px;background:rgba(255,255,255,.6);
}
body.is-mobile .day-shift.rest{color:var(--rest)}
body.is-mobile .day-shift.cell.ro{background:rgba(255,255,255,.55)}

/* 日历紧凑 */
body.is-mobile .cal-cell{padding:6px 2px;min-height:54px}
body.is-mobile .cal-cell .d{font-size:11px}
body.is-mobile .cal-cell .sh{font-size:13px}
body.is-mobile .cal-cell .tm{font-size:9px}
/* 卡片紧凑 */
body.is-mobile .kpi{padding:11px 13px}
body.is-mobile .kpi .v{font-size:20px}
body.is-mobile .tabs-gone-empty{display:none}

/* 移动端 "更多" 面板 */
.more-grid{display:flex;flex-direction:column;gap:8px;margin-top:6px}
.more-btn{
  display:flex;align-items:center;gap:12px;
  background:#fff;border:1px solid var(--line);border-radius:12px;padding:12px;
  cursor:pointer;text-align:left;font-family:inherit;
}
.more-btn:active{transform:scale(.99)}
.more-ico{font-size:24px;width:36px;text-align:center}
.more-info{flex:1;min-width:0}
.more-label{font-weight:700;font-size:15px}
.more-desc{font-size:12px;color:var(--muted);margin-top:2px}
.more-arr{color:#aaa;font-size:20px}
