/* =========================================================
   值班日历后台 - 森林消防战备值班系统主题
   深松绿 × 防火橙
   ========================================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --pine-900: #16301F;
  --pine-700: #2A5C40;
  --pine-500: #3E7B58;
  --pine-100: #E9F1EC;
  --ember: #D9602B;
  --ember-100: #FBE9DF;
  --alert: #B4432C;
  --paper: #F4F6F3;
  --card: #FFFFFF;
  --ink: #22302A;
  --muted: #6C7B72;
  --line: #DCE4DD;
  --shadow: 0 2px 10px rgba(22, 48, 31, .08);
  --shadow-float: 0 -4px 18px rgba(22, 48, 31, .10);
  --r-card: 10px;
  --r-btn: 8px;
}
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
.hidden { display: none !important; }
/* 兜底：不让页面出现横向滚动条（手机端日历最容易撑破）。
   注意必须用 clip 而不是 hidden —— overflow:hidden 会让 body 成为滚动容器，
   把 .edit-bar（保存栏）的 position:sticky 弄失效；clip 不创建滚动容器，sticky 照常。 */
body { overflow-x: clip; }
@supports not (overflow-x: clip) { body { overflow-x: hidden; } }

/* 首屏正在用 cookie 探测「我是谁」（见 app.js 的 restoreSession）。
   这段时间先别闪登录框：显示带品牌图标的启动画面（同一张森林背景），
   通常只有一两百毫秒，网络差时也不会显得「白屏 + 一行小字」那么傻。 */
body.booting #authView { visibility: hidden; }
.boot-splash {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(160deg, rgba(8, 20, 13, .88) 0%, rgba(16, 37, 26, .80) 55%, rgba(42, 92, 64, .70) 100%),
    url(/bg-login.jpg) center/cover no-repeat,
    #10251A;
}
body:not(.booting) .boot-splash { display: none; }
.boot-inner { text-align: center; padding: 0 24px; }
.boot-icon {
  width: 92px;
  height: 92px;
  border-radius: 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
.boot-title {
  margin-top: 18px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 5px;
  color: #F5EFE0;
}
.boot-sub {
  margin-top: 9px;
  font-size: 12.5px;
  letter-spacing: 1.5px;
  color: rgba(245, 239, 224, .62);
}
.boot-bar {
  width: 96px;
  height: 3px;
  margin: 26px auto 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  overflow: hidden;
}
.boot-bar i {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 999px;
  background: var(--ember);
  animation: bootSlide 1.05s ease-in-out infinite;
}
@keyframes bootSlide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(260%); }
}
@media (prefers-reduced-motion: reduce) {
  .boot-bar i { animation: none; width: 100%; opacity: .5; }
}

/* ---------- 登录 ---------- */
.auth-wrap {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 底部多留一点，备案号页脚才压不到登录卡片 */
  padding: 20px 20px 64px;
  background:
    linear-gradient(160deg, rgba(8, 20, 13, .90) 0%, rgba(16, 37, 26, .82) 46%, rgba(30, 66, 45, .72) 100%),
    url(/bg-login.jpg) center/cover no-repeat,
    linear-gradient(160deg, #10251A 0%, var(--pine-900) 48%, var(--pine-700) 100%);
}

/* ---------- 备案号页脚（工信部要求首页底部显著标明并链接备案系统） ---------- */
.site-footer {
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  letter-spacing: .02em;
}
.site-footer a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
  padding-bottom: 1px;
  opacity: .9;
}
.site-footer a:hover { opacity: 1; }
.auth-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  color: rgba(255, 255, 255, .68);
}
.auth-footer a:hover { color: #fff; }
.main-footer {
  margin-top: 26px;
  padding: 14px 16px 10px;
  color: var(--muted);
}
.main-footer a:hover { color: var(--pine-700); border-bottom-style: solid; }
.auth-card {
  width: 384px;
  max-width: 94vw;
  background: var(--card);
  border-radius: 14px;
  padding: 34px 32px 28px;
  box-shadow: 0 20px 60px rgba(8, 22, 13, .45);
}
.auth-brand { text-align: center; margin-bottom: 4px; }
.auth-logo {
  font-size: 28px;
  font-weight: 800;
  color: var(--pine-900);
  letter-spacing: 4px;
  line-height: 1.2;
}
.auth-sub {
  text-align: center;
  color: var(--pine-500);
  margin: 8px 0 0;
  font-size: 13px;
  letter-spacing: 1px;
}
.auth-mode {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: 18px 0 16px;
  padding: 8px 0;
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
}
.form-item { margin-bottom: 14px; }
.form-item label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.form-item input, .form-item select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  font-size: 14px;
  outline: none;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.form-item input:focus, .form-item select:focus {
  border-color: var(--pine-500);
  box-shadow: 0 0 0 3px rgba(62, 123, 88, .15);
}
.form-item.inline { display: flex; align-items: center; gap: 8px; margin-bottom: 0; }
.form-item.inline label { margin-bottom: 0; white-space: nowrap; }
.form-item.inline select { width: 148px; }
.cap-row { display: flex; gap: 10px; align-items: stretch; }
.cap-row input { flex: 1; }
.cap-img {
  width: 128px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  cursor: pointer;
  background: var(--pine-100);
  object-fit: cover;
}
.auth-err { color: var(--alert); font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 16px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.remember-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--pine-700);
  cursor: pointer;
  flex: 0 0 auto;
}

/* ---------- 按钮 ---------- */
.btn {
  padding: 9px 18px;
  border: none;
  border-radius: var(--r-btn);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { filter: brightness(.94); }
.btn-block { width: 100%; }
.btn-primary { background: var(--pine-900); color: #fff; }
.btn-primary:hover { background: var(--pine-700); filter: none; }
.btn-danger { background: var(--alert); color: #fff; }
.btn-danger:hover { background: #962E1E; filter: none; }
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: var(--r-btn);
}
.btn-sm:hover { border-color: var(--pine-500); color: var(--pine-700); filter: none; background: var(--pine-100); }

/* ---------- 主框架 ---------- */
.main-wrap { max-width: 1400px; margin: 0 auto; padding: 0 16px 48px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--pine-900);
  color: #fff;
  border-radius: 12px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}
.topbar-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-logo { width: 48px; height: 48px; object-fit: contain; border-radius: 8px; background: rgba(255,255,255,.12); padding: 4px; }
.topbar-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.topbar-name { font-size: 20px; font-weight: 800; color: #fff; line-height: 1.3; letter-spacing: .5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub { font-size: 12px; color: rgba(255,255,255,.72); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.whoami-label { font-size: 12px; color: rgba(255,255,255,.6); }
.whoami { color: #fff; font-weight: 700; font-size: 14px; }
.link-btn {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: var(--r-btn);
  transition: color .15s, border-color .15s, background .15s;
}
.link-btn:hover { color: #fff; background: var(--alert); border-color: var(--alert); }

/* ---------- 标签导航 ---------- */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  margin: 12px 0 18px;
  box-shadow: var(--shadow);
}
.tab-btn {
  padding: 10px 22px;
  border: none;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--r-btn);
  position: relative;
  transition: color .15s, background .15s;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--pine-700); background: var(--pine-100); }
.tab-btn.active { color: var(--ink); background: var(--pine-100); }
.tab-btn.active::after {
  content: "";
  position: absolute;
  left: 18px; right: 18px; bottom: 5px;
  height: 3px;
  border-radius: 2px;
  background: var(--pine-900);
}
.tab-panel { animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- 面板头部 ---------- */
.panel-head {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.year-switch { display: flex; align-items: center; gap: 8px; }
.year-label { font-size: 17px; font-weight: 800; color: var(--ink); min-width: 76px; text-align: center; font-variant-numeric: tabular-nums; }
.month-nav { display: flex; gap: 5px; flex-wrap: wrap; }
.month-nav button {
  padding: 6px 13px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--r-btn);
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
  transition: all .15s;
}
.month-nav button:hover { border-color: var(--pine-500); color: var(--pine-700); }
.month-nav button.active { background: var(--pine-900); color: #fff; border-color: var(--pine-900); font-weight: 700; }
.view-tip { color: var(--muted); font-size: 12px; margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tip-text { background: var(--pine-100); color: var(--pine-700); padding: 4px 10px; border-radius: 999px; }

/* ---------- 日历 ---------- */
.cal-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.cal-month-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--pine-900);
  display: flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.cal-month-title::before { content: ""; width: 6px; height: 18px; border-radius: 3px; background: var(--ember); }
/* minmax(0,1fr) 而不是 1fr：1fr 等价于 minmax(auto,1fr)，轨道最小宽度会退到内容的
   min-content 宽度；格内姓名 white-space:nowrap 时会撑爆整行，导致整页横向溢出。 */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal-head {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--pine-700);
  padding: 8px 0;
  background: var(--pine-100);
  border-radius: 6px;
}
.cal-head.weekend { color: var(--ember); background: var(--ember-100); }
.cal-cell {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 8px 9px;
  cursor: pointer;
  background: var(--card);
  position: relative;
  overflow: hidden;
  min-width: 0;
  transition: box-shadow .15s, border-color .15s;
}
.cal-cell:hover { box-shadow: var(--shadow); border-color: var(--pine-500); }
.cal-cell.empty { background: transparent; cursor: default; border-style: dashed; box-shadow: none; }
.cal-cell.empty:hover { border-color: var(--line); }
/* ---------- 「今天」高亮 ----------
   原来只有 outline + 淡呼吸光晕，静帧下几乎看不出差别（截图正好抓到 0% 帧就是完全无光晕）。
   现在三重提示：橙色实心日期圆 + 右上角「今天」角标 + 橙色内描边 + 外光晕。
   内描边用 inset box-shadow 而不是加粗 border —— border 变宽会让格内容位移，
   在 grid 里引起整行重排。 */
.cal-cell.today {
  border-color: var(--ember);
  box-shadow:
    inset 0 0 0 1.5px var(--ember),
    0 0 0 3px rgba(217, 96, 43, .16),
    0 6px 18px rgba(217, 96, 43, .16);
  animation: todayPulse 2.4s ease-in-out infinite;
}
@keyframes todayPulse {
  0%, 100% {
    box-shadow:
      inset 0 0 0 1.5px var(--ember),
      0 0 0 3px rgba(217, 96, 43, .16),
      0 6px 18px rgba(217, 96, 43, .16);
  }
  50% {
    box-shadow:
      inset 0 0 0 1.5px var(--ember),
      0 0 0 9px rgba(217, 96, 43, .06),
      0 8px 28px rgba(217, 96, 43, .30);
  }
}
@media (prefers-reduced-motion: reduce) {
  .cal-cell.today { animation: none; }
}
.cal-cell.today .cal-date {
  display: flex;
  width: fit-content; /* flex 会被拉成整行宽，圆变椭圆；钉回内容宽 */
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px; /* 与普通日期行同高，行内容才纵向对齐 */
  padding: 0 6px;
  border-radius: 999px;
  background: var(--ember);
  color: #fff;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(217, 96, 43, .38);
}
.cal-cell.today::after {
  content: "今天";
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 2;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--ember);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: .5px;
  pointer-events: none;
}
.cal-cell.selected { background: var(--pine-100); border-color: var(--pine-700); }
.cal-cell.selected.today { border-color: var(--ember); }
.cal-cell.cal-fire {
  background: var(--ember-100);
  border-color: #F2CFC2;
  border-left: 4px solid var(--ember);
  padding-left: 6px;
}
.cal-date {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  /* 所有格子（含「今天」的实心圆）统一日期行盒高：
     否则今天的圆比普通日期行高，把本格药丸整体挤低几像素，
     手机上看起来就是「今天的格子排版和别的格子不一样」 */
  line-height: 22px;
  height: 22px;
  display: flex;
  align-items: center;
}
.cal-date.weekend { color: var(--ember); }
.cal-duty { margin-top: 6px; font-size: 12px; line-height: 1.5; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
/* 关键：不再用 overflow-wrap:anywhere（它允许在任意字符处断行，格窄时会把姓名拆成一字一行）。
   改为「标签不收缩 + 姓名超长省略」，保证永远横向排版。 */
.cal-duty span {
  max-width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-duty span .lb { flex: 0 0 auto; font-weight: 500; opacity: .92; }
.cal-duty span .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.cal-duty .l {
  background: #D9602B;
  color: #fff;
  border-radius: 999px;
  padding: 1px 9px;
  font-weight: 600;
}
.cal-duty .c {
  background: #2F6FB3;
  color: #fff;
  border-radius: 999px;
  padding: 1px 9px;
  font-weight: 600;
}
.cal-duty .m {
  background: #2E7D32;
  color: #fff;
  border-radius: 999px;
  padding: 1px 9px;
  font-weight: 600;
}
.cal-duty .none { color: #B4BEB7; font-style: italic; align-self: flex-start; background: transparent; }
.cal-count {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ember);
  background: var(--ember-100);
  border-radius: 999px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- 今日值班横幅 ---------- */
.today-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, var(--pine-900) 0%, var(--pine-700) 100%);
  color: #fff;
  border-radius: 12px;
  padding: 12px 18px;
  margin: 0 0 18px;
  box-shadow: var(--shadow);
}
.today-bar-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; letter-spacing: 1px; }
.today-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ember); box-shadow: 0 0 0 4px rgba(217, 96, 43, .28); }
.today-date { font-size: 13px; font-weight: 600; background: rgba(255,255,255,.16); padding: 3px 10px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.today-duty { display: flex; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.today-item { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.12); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.today-item-key { color: rgba(255,255,255,.72); }
.today-item-val { font-weight: 700; }
.today-bar.no-data .today-duty { opacity: .7; }
@media (max-width: 720px) {
  .today-bar { padding: 10px 14px; }
  .today-duty { margin-left: 0; width: 100%; }
}

/* ---------- 编辑值班 ---------- */
.edit-bar {
  position: sticky;
  bottom: 16px;
  z-index: 50;
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-float);
}
.edit-persons { display: flex; gap: 14px; flex-wrap: wrap; }
.edit-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.edit-count {
  color: var(--ember);
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: var(--ember-100);
  padding: 5px 14px;
  border-radius: 999px;
}
.edit-msg { margin-top: 12px; color: var(--pine-700); font-size: 13px; min-height: 16px; }
.edit-msg.err { color: var(--alert); }

/* ---------- 值班统计 ---------- */
.stats-box {
  margin-top: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stats-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.stats-range { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.stats-range input[type="date"] {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}
.stats-quick { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.quick-btn {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.quick-btn:hover { border-color: var(--pine-900); background: var(--pine-900); color: #fff; }
.stats-result { min-height: 60px; }
.stats-summary { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.stats-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stats-col { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px 16px; }
.stats-col-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--pine-900);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
.stats-col-title::before { content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--ember); }
.stats-empty { color: var(--muted); text-align: center; padding: 20px 0; font-size: 14px; }
.stats-list { list-style: none; margin: 0; padding: 0; }
.stats-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 2px; border-bottom: 1px dotted var(--line); }
.stats-list li:last-child { border-bottom: none; }
.stats-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.stats-days { font-size: 13px; font-weight: 700; color: var(--ember); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .stats-cols { grid-template-columns: 1fr; } }

/* ---------- 人员管理 ---------- */
.persons-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.person-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 16px;
  box-shadow: var(--shadow);
}
.person-box h3 {
  font-size: 15px;
  font-weight: 800;
  color: var(--pine-900);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.person-box h3::before { content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--pine-500); }
.person-list { min-height: 60px; display: flex; flex-wrap: wrap; gap: 6px; }
.person-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--pine-100);
  border: 1px solid #D2E0D7;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--pine-900);
  font-weight: 500;
}
.person-tag .del { color: #AEBAB2; cursor: pointer; font-weight: 700; font-size: 14px; line-height: 1; transition: color .15s; }
.person-tag .del:hover { color: var(--alert); }
.person-add { display: flex; gap: 8px; margin-top: 12px; }
.person-add input { flex: 1; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-btn); outline: none; }
.person-add input:focus { border-color: var(--pine-500); box-shadow: 0 0 0 3px rgba(62,123,88,.12); }
.person-msg { margin-top: 12px; color: var(--pine-700); font-size: 13px; min-height: 16px; }
.person-msg.err { color: var(--alert); }
@media (max-width: 900px) { .persons-grid { grid-template-columns: 1fr; } }

/* ---------- 账号 ---------- */
.account-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 18px;
  max-width: 420px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.account-box h3 { font-size: 15px; font-weight: 800; color: var(--pine-900); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.account-box h3::before { content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--ember); }
.account-box p { color: var(--ink); font-size: 15px; font-weight: 600; }
.account-role { color: var(--pine-700) !important; font-size: 13px !important; font-weight: 700 !important; margin-top: 4px; }

/* ---------- 用户管理（仅管理员） ---------- */
.users-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.users-box h3 {
  font-size: 15px;
  font-weight: 800;
  color: var(--pine-900);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.users-box h3::before { content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--ember); }
.users-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.users-head h3 { margin-bottom: 0; }
.users-note { font-size: 12px; color: var(--muted); line-height: 1.5; }
.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-empty { color: var(--muted); font-size: 13px; padding: 14px 0; text-align: center; }
.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  background: #FBFCFB;
}
.user-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-name { font-size: 14px; font-weight: 700; color: var(--ink); word-break: break-all; }
.user-name .user-self {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  color: var(--pine-700);
  background: var(--pine-100);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 4px;
}
.user-name .user-self.super { color: #B8860B; background: #FBF0DC; }
/* 用户列表里的账号名（姓名旁边的灰色小字） */
.user-account { font-size: 12px; color: var(--muted); word-break: break-all; }
.user-role {
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}
.user-role.r-admin { color: #fff; background: var(--pine-700); }
.user-role.r-viewer { color: var(--pine-900); background: var(--pine-100); border: 1px solid #D2E0D7; }
.user-tag {
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  background: #EFF2EF;
}
.user-tag.off { color: var(--alert); background: #FBEAE6; }
.user-ops { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--pine-700);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  padding: 5px 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.mini-btn:hover { background: var(--pine-100); border-color: #C5DACD; }
.mini-btn.danger { color: var(--alert); border-color: #F0D5CE; }
.mini-btn.danger:hover { background: #FBEAE6; border-color: #E3B7AC; }
.user-add { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.user-add .form-item.inline { flex-direction: column; align-items: flex-start; gap: 6px; }
.user-add .form-item.inline input,
.user-add .form-item.inline select { width: 180px; }
.user-add .btn { flex: 0 0 auto; }

/* 查看员：顶栏加角色标记，写入口全部隐藏 */
body.role-viewer .whoami::after {
  content: "查看员";
  margin-left: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  color: #fff;
  background: var(--ember);
  border-radius: 999px;
  padding: 2px 9px;
  vertical-align: 1px;
}

@media (max-width: 900px) {
  .user-row { align-items: flex-start; }
  .user-ops { width: 100%; }
  .user-add { flex-direction: column; align-items: stretch; }
  .user-add .form-item.inline input,
  .user-add .form-item.inline select { width: 100%; }
}

/* ---------- 日历图例（窄屏隐藏标签后靠颜色区分角色，必须给图例） ---------- */
.cal-legend { display: none; margin-top: 10px; gap: 12px; flex-wrap: wrap; align-items: center; }
.cal-legend .lg { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.cal-legend .lg::before { content: ""; width: 10px; height: 10px; border-radius: 3px; }
.cal-legend .lg-leader::before { background: #D9602B; }
.cal-legend .lg-cadre::before { background: #2F6FB3; }
.cal-legend .lg-member::before { background: #2E7D32; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 32, 24, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-box {
  background: var(--card);
  border-radius: 14px;
  width: 360px;
  max-width: 92vw;
  padding: 24px;
  position: relative;
  box-shadow: 0 20px 50px rgba(10, 25, 16, .30);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color .15s, background .15s;
}
.modal-close:hover { color: #fff; background: var(--alert); }
.detail-date {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--pine-900);
  font-variant-numeric: tabular-nums;
}
.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px dotted var(--line); font-size: 14px; }
.detail-row .k { color: var(--muted); }
.detail-row .v { font-weight: 700; }
.detail-row .v.leader { color: var(--pine-900); }
.detail-row .v.cadre { color: var(--pine-700); }
.detail-row .v.member { color: #5A6B61; }
.detail-row .v.weather { color: var(--ember); }
.detail-row .v.hum { color: var(--pine-700); }
.detail-row .v.rain { color: var(--pine-500); }
.week-red { color: var(--ember); }

/* ---------- 领导筛选 ---------- */
.leader-filter { display: inline-flex; align-items: center; gap: 6px; }
.leader-filter select {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
}
.cal-cell.leader-hit { border-color: var(--pine-700); box-shadow: var(--shadow); }
.cal-cell.leader-hit .cal-duty span.l { background: var(--ember); }

/* ---------- 未来天气预测 ---------- */
.fc-box {
  margin-top: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.fc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.fc-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--pine-900);
  display: flex;
  align-items: center;
  gap: 8px;
}
.fc-title::before { content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--ember); }
.fc-strip { display: flex; gap: 8px; }
.fc-item {
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--paper);
  padding: 10px 8px;
  text-align: center;
}
.fc-item.fc-today { border-color: var(--pine-700); background: var(--pine-100); }
.fc-top { display: flex; align-items: center; justify-content: center; gap: 4px; }
.fc-week { font-size: 13px; font-weight: 700; color: var(--pine-900); }
.fc-tag {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--ember);
  border-radius: 999px;
  padding: 1px 5px;
  line-height: 1.5;
}
.fc-date { font-size: 11px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.fc-wx { font-size: 13px; font-weight: 700; color: var(--ember); margin: 7px 0 3px; overflow-wrap: anywhere; }
.fc-temp { font-size: 13px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.fc-wind, .fc-hum { font-size: 11px; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.fc-empty { color: var(--muted); font-size: 13px; padding: 10px 0; }
.fc-disc {
  margin-top: 12px;
  font-size: 11px;
  color: #8A5A3B;
  background: var(--ember-100);
  border-radius: 6px;
  padding: 6px 10px;
}
@media (max-width: 900px) {
  .fc-strip { overflow-x: auto; padding-bottom: 4px; }
  .fc-item { flex: 0 0 96px; }
}

/* ---------- 移动端 ---------- */
@media (max-width: 720px) {
  .main-wrap { padding: 0 10px 40px; }
  .topbar { flex-wrap: wrap; padding: 10px 14px; }
  .topbar-name { font-size: 16px; }
  .topbar-logo { width: 38px; height: 38px; }
  .tabs { overflow-x: auto; }
  .tab-btn { padding: 8px 14px; font-size: 14px; }
  .cal-cell { min-height: 52px; padding: 4px 5px; }
  .cal-month-title { font-size: 15px; }
  .cal-date { font-size: 13px; }
  .cal-duty { font-size: 11px; gap: 3px; margin-top: 3px; }
  .cal-duty span { padding: 0 4px; }
  .view-tip { margin-left: 0; width: 100%; }
  .edit-bar { flex-direction: column; align-items: stretch; position: sticky; bottom: 8px; }
  .edit-persons { flex-direction: column; }
  .edit-actions { justify-content: flex-end; }
  .form-item.inline select { width: 100%; }
}

/* ---------- App 指纹解锁开关 ---------- */

/* ---------- 响应式（<=900px：手机 / 平板竖屏） ---------- */
@media (max-width: 900px) {
  html { -webkit-text-size-adjust: 100%; }
  .main-wrap { padding: 0 12px calc(40px + env(safe-area-inset-bottom)); }
  .topbar { flex-wrap: wrap; padding: 10px 14px; gap: 8px; }
  /* 顶栏标题：原来写死 nowrap+ellipsis，长单位名必被截；窄屏改为可换行，宁可变高的两行 */
  .topbar-title { min-width: 0; flex: 1 1 auto; }
  .topbar-text { min-width: 0; }
  .topbar-logo { flex: 0 0 auto; }
  .topbar-name {
    font-size: 15px;
    line-height: 1.35;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
    /* 360/375 宽时 19 字标题差 1~6px 放不下，普通换行会剩一个孤字「历」；
       balance 让两行均分。不支持的旧内核退回普通换行，不影响完整性。 */
    text-wrap: balance;
  }
  .topbar-right { flex: 0 0 auto; }
  .topbar-sub { display: none; }
  .topbar-logo { width: 36px; height: 36px; }
  .topbar-right { gap: 8px; }

  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { padding: 9px 15px; font-size: 14px; white-space: nowrap; }

  /* 竖排必须关掉 flex-wrap：column + wrap 会让子项可用高度计算失真，
     .month-nav 被撑到 524px（实际内容只有 126px），下方留出大片空白 */
  .panel-head { flex-direction: column; align-items: stretch; gap: 10px; flex-wrap: nowrap; }
  .year-switch { justify-content: center; }
  .month-nav { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .month-nav button { flex: 0 0 auto; min-width: 44px; }
  .view-tip { margin-left: 0; width: 100%; }
  .leader-filter { margin-left: 0; display: flex; align-items: center; gap: 8px; }
  .leader-filter { flex-wrap: wrap; }
  /* select 的 min-width 默认是 auto(=内容宽度)，不显式归零就压不下去，「全部领导」会撑破行 */
  .leader-filter select { flex: 1 1 auto; min-width: 0; max-width: 100%; }

  .cal-grid { gap: 3px; }
  .cal-cell { min-height: 58px; padding: 4px 5px; }
  .cal-month-title { font-size: 15px; }
  .cal-date { font-size: 13px; }
  .cal-duty { font-size: 11px; gap: 3px; margin-top: 3px; }
  .cal-duty span { padding: 0 4px; }

  .fc-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .fc-strip { overflow-x: auto; padding-bottom: 4px; }
  .fc-item { flex: 0 0 96px; }

  .stats-box { padding: 14px; }
  .stats-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .stats-range { flex-wrap: wrap; }
  .stats-range input[type="date"] { flex: 1 1 120px; min-width: 0; }

  .edit-bar { position: static; flex-direction: column; align-items: stretch; }
  .edit-persons { flex-direction: column; }
  .edit-actions { justify-content: flex-end; }
  .form-item.inline select { width: 100%; }

  .modal-box { width: 94vw; max-width: 94vw; margin: 18px auto; max-height: 84vh; overflow-y: auto; }
  .detail-row { font-size: 14px; }

  .auth-wrap { padding: 16px; }
  .auth-card { width: 100%; max-width: 100%; }

  /* 触控友好尺寸 */
  .btn, .tab-btn, .quick-btn, .month-nav button, .link-btn { min-height: 38px; }
  input[type="text"], input[type="password"], input[type="date"], select { min-height: 38px; font-size: 15px; }
}

/* ---------- 平板/窄屏（<=820px）：格子里放不下「带班/干部/成员」标签 ---------- */
@media (max-width: 820px) {
  /* 标签占 22px + 4px 间距，而 641~820 的格子只有 80~105px 宽，3 个汉字姓名
     (41px) 必被省略号吃掉；角色改由色块 + 图例表达，与手机端保持一致 */
  .cal-duty span .lb { display: none; }
  .cal-duty span { justify-content: center; }
}

/* ---------- 手机日历（<=640px）：只留姓名，靠颜色区分角色 ---------- */
@media (max-width: 640px) {
  .cal-wrap { padding: 12px 8px; }
  .cal-grid { gap: 3px; }
  .cal-cell { min-height: 52px; padding: 4px 3px; border-radius: 8px; }
  /* 防火期单元格左侧会多占 4px 边框 + 6px 内边距，窄屏下压到 2px/3px 把宽度抢回来 */
  .cal-cell.cal-fire { border-left-width: 2px; padding-left: 3px; }
  .cal-date { font-size: 12px; line-height: 19px; height: 19px; }
  /* 「今天」的角标在 47px 的格子里会和日期圆打架（25 + 30 = 55 > 47），
     窄屏只留日期圆 + 橙色描边，醒目度已经够 */
  .cal-cell.today::after { display: none; }
  .cal-cell.today .cal-date { width: fit-content; min-width: 19px; height: 19px; padding: 0 3px; font-size: 11px; }
  .cal-duty { margin-top: 2px; gap: 2px; font-size: 10px; line-height: 1.35; }
  .cal-duty span { padding: 0 3px; border-radius: 4px; justify-content: center; gap: 0; }
  .cal-duty span .lb { display: none; }          /* 窄屏隐藏「带班/干部/成员」，只保留姓名 */
  /* 角色色块原本 padding:1px 9px（左右 18px），390 宽时格子才 47px、内容区 41px，
     姓名只剩 23px，3 个汉字必被省略号吃掉。窄屏把水平内边距压到 2px 还回去。
     注意必须写到 .cal-duty span.l 这一层，否则特异性输给 .cal-duty .l。 */
  .cal-duty span.l, .cal-duty span.c, .cal-duty span.m { padding: 0 2px; }
  .cal-duty .none { padding: 0; font-size: 10px; }
  /* 标题 19 字 × 15px + letter-spacing .5px = 294px，比可用宽度 288px 多 6px，
     硬生生把末字「历」挤成第二行孤字。去掉字距并降到 14px 就能单行完整显示。 */
  .topbar-name { font-size: 14px; letter-spacing: 0; }
  .topbar-right { margin-left: auto; }
  .cal-head { font-size: 12px; padding: 6px 0; }
  .cal-legend { display: flex; }
  /* 12 个月按钮 flex-wrap 会排成 6/5/1，12 月孤零零占一行；改 auto-fit 网格，
     390 宽时 76px 一列正好 4 列 × 3 行 */
  .month-nav {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 6px; overflow: visible;
    /* 网格的 align-content 默认是 stretch，在 flex 列容器里会把 3 行摊平成 170px 一行；
       钉成 start 让行高回到内容高度 */
    align-content: start; grid-auto-rows: auto;
  }
  .month-nav button { min-width: 0; padding: 6px 0; }
}

@media (max-width: 400px) {
  /* 原来是 3px 4px，窄屏反而把水平内边距加大了：47.14 - 2(边框) - 8 - 4(药丸) = 33px，
     装不下 3 个汉字（约 35px）会被省略。收窄到 2px 后可得 37px。 */
  .cal-cell { min-height: 50px; padding: 3px 2px; }
  .cal-duty { font-size: 10px; }
  /* 再挤出 2px：390 时格子内容区 41px，3 个汉字姓名约 36px，药丸内边距压到 1px 才够 */
  .cal-duty span.l, .cal-duty span.c, .cal-duty span.m { padding: 0 1px; }
  .fc-item { flex: 0 0 88px; }
  .topbar-name { font-size: 14px; }
}

/* ---------- 极小屏（<=340px，如 iPhone SE 一代）：格子只剩 37px ---------- */
@media (max-width: 340px) {
  /* 格子只有 37px：10px 三个汉字要 36px，而防火期单元格还有 2px 左边框。
     先把水平内边距归零（多出 4px），再降字号、去药丸内边距 */
  .cal-cell { padding: 3px 0; }
  .cal-duty { font-size: 9px; }
  .cal-duty span.l, .cal-duty span.c, .cal-duty span.m { padding: 0; }
}

/* =========================================================
   模块选择（值班日历 / 备忘录）
   ========================================================= */
/* 进入某个模块时隐藏另一个模块的 DOM。用 body class 控制而不是再包一层容器，
   避免把已调好的日历布局（grid 轨道、sticky 保存栏）搞乱 */
body.mod-chooser .tabs,
body.mod-chooser #todayBar,
body.mod-chooser .tab-panel,
body.mod-memos .tabs,
body.mod-memos #todayBar,
body.mod-memos .tab-panel,
body.mod-users .tabs,
body.mod-users #todayBar,
body.mod-users .tab-panel,
body.mod-account .tabs,
body.mod-account #todayBar,
body.mod-account .tab-panel { display: none !important; }
/* 用户/账号是独立模块，但复用 tab-panel 承载：进入时单独放行对应面板 */
body.mod-users #tab-users,
body.mod-account #tab-account { display: block !important; }

/* 顶栏用户菜单：点用户名弹出（退出登录） */
.user-menu-wrap { position: relative; }
button.whoami {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: inherit;
}
button.whoami:hover { background: rgba(255, 255, 255, .22); }
.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 132px;
  background: var(--card, #fff);
  border: 1px solid var(--line, #ddd);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(22, 48, 31, .18);
  padding: 6px;
}
.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #c0392b;
  background: transparent;
  border: 0;
  border-radius: 7px;
  padding: 8px 12px;
  cursor: pointer;
  font-family: inherit;
}
.user-menu-item:hover { background: rgba(192, 57, 43, .08); }

.module-switch {
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, .38);
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.module-switch:hover { background: rgba(255, 255, 255, .24); }

.chooser {
  max-width: 880px;
  margin: 0 auto;
  padding: 52px 16px 72px;
}
.chooser-head { text-align: center; margin-bottom: 30px; }
.chooser-head h2 { font-size: 21px; font-weight: 800; color: var(--ink); letter-spacing: .5px; }
.chooser-head p { margin-top: 8px; font-size: 13px; color: var(--muted); }
.chooser-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.chooser-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  text-align: left;
  padding: 24px 22px 20px;
  min-height: 188px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.chooser-card:hover {
  border-color: var(--pine-500);
  box-shadow: 0 10px 28px rgba(22, 48, 31, .12);
  transform: translateY(-2px);
}
.chooser-card.memo:hover {
  border-color: var(--ember);
  box-shadow: 0 10px 28px rgba(217, 96, 43, .16);
}
.chooser-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pine-100);
  color: var(--pine-700);
  margin-bottom: 4px;
}
.chooser-card.memo .chooser-icon { background: var(--ember-100); color: var(--ember); }
/* 用户管理 / 账号管理图标配色 */
.chooser-card .chooser-icon.ci-user { background: #E8F0FB; color: #2F6FB3; }
.chooser-card .chooser-icon.ci-gear { background: #F1EDE4; color: #8A6D1D; }
.chooser-name { font-size: 17px; font-weight: 800; color: var(--ink); }
.chooser-desc { font-size: 13px; color: var(--muted); line-height: 1.6; }
.chooser-go { margin-top: auto; padding-top: 10px; font-size: 13px; font-weight: 700; color: var(--pine-700); }
.chooser-card.memo .chooser-go { color: var(--ember); }

/* =========================================================
   备忘录（上报文件登记台账）
   ========================================================= */
.memo-wrap { max-width: 1180px; margin: 0 auto; padding: 22px 16px 64px; }
.memo-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.memo-head-title { display: flex; align-items: baseline; gap: 10px; }
.memo-head-title h2 { font-size: 18px; font-weight: 800; color: var(--ink); }
.memo-count { font-size: 13px; color: var(--muted); }
.memo-head-actions { display: flex; gap: 10px; align-items: center; }
.memo-search {
  width: 250px;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: #fff;
  color: var(--ink);
}
.memo-search:focus { border-color: var(--pine-500); box-shadow: 0 0 0 3px rgba(62, 123, 88, .15); }

/* 筛选区：一整块浅卡片，每行「标签 + 胶囊组」左侧对齐。
   之前是 space-between 的两组自由流，窄屏换行后左右参差，看着散。 */
.memo-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 28px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
}
.memo-filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.filter-label {
  flex: 0 0 auto;
  min-width: 30px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .02em;
}
.memo-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 13px;
  font-size: 13px;
  font-family: inherit;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--pine-500); color: var(--pine-700); }
.chip.active { background: var(--pine-700); border-color: var(--pine-700); color: #fff; }
.memo-seal-filter .chip.active { background: var(--ember); border-color: var(--ember); }

.memo-list { display: flex; flex-direction: column; gap: 10px; }
.memo-card {
  display: flex;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--pine-100);
  border-radius: var(--r-card);
  padding: 14px 16px;
}
.memo-card.is-soon { border-left-color: var(--ember); background: #FFFCFA; }
.memo-card.is-overdue { border-left-color: var(--alert); background: #FEF9F8; }
.memo-card.is-finished { opacity: .76; }
.memo-card-main { flex: 1; min-width: 0; }
.memo-card-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.memo-card-title b { font-size: 15px; font-weight: 800; color: var(--ink); }
.memo-urgent {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--ember-100);
  color: var(--ember);
  white-space: nowrap;
}
.memo-urgent.u-flash { background: #FBE3DF; color: var(--alert); }
.memo-docno { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.memo-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
/* 截止日期：独占一行、排在部门之上，并加浅底色块 —— 上报台账最要紧的是时限，
   原来混在部门/盖章的小字里几乎看不见 */
.memo-due-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 100%;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 8px;
  background: #EAF2ED;
  font-size: 13.5px;
  line-height: 1.5;
}
.memo-due-row .due-k { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.memo-due-row .due-v {
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}
.memo-due-row .due-flag {
  font-size: 11px;
  font-weight: 700;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--pine-100);
  color: var(--pine-700);
  white-space: nowrap;
}
/* 临期 / 逾期整块换色，扫一眼就能挑出要催的 */
.memo-card.is-soon .memo-due-row { background: var(--ember-100); }
.memo-card.is-soon .memo-due-row .due-k { color: var(--ember); }
.memo-card.is-soon .memo-due-row .due-v { color: var(--ember); }
.memo-card.is-soon .memo-due-row .due-flag { background: #fff; color: var(--ember); }
.memo-card.is-overdue .memo-due-row { background: #FBE3DF; }
.memo-card.is-overdue .memo-due-row .due-k { color: var(--alert); }
.memo-card.is-overdue .memo-due-row .due-v { color: var(--alert); }
.memo-card.is-overdue .memo-due-row .due-flag { background: #fff; color: var(--alert); }
.memo-card.is-finished .memo-due-row { background: #F4F4F2; }
.memo-card.is-finished .memo-due-row .due-v { color: var(--muted); font-weight: 700; }
.memo-tag { font-size: 12px; }
.memo-tag.dept { background: rgba(62,123,88,.10); color: var(--pine-700); padding: 1px 7px; border-radius: 9px; font-weight: 600; }
/* 盖章徽章紧跟部门，两者都偏绿容易糊成一片：
   部门用实心浅绿底，盖章改用「描边空心 + 橙色印色」，一眼分得清 */
.memo-seal {
  font-size: 11px;
  font-weight: 700;
  padding: 0 6px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(62,123,88,.48);
  color: var(--pine-700);
  white-space: nowrap;
}
.memo-card-note {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.memo-card-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex: 0 0 auto;
}
.memo-status {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.memo-status.todo { background: var(--ember-100); color: var(--ember); }
.memo-status.done { background: var(--pine-100); color: var(--pine-700); }
.memo-done-line { font-size: 11px; color: var(--muted); white-space: nowrap; }
.memo-ops { display: flex; gap: 6px; margin-top: 2px; flex-wrap: wrap; justify-content: flex-end; }
.memo-ops .btn-sm { white-space: nowrap; }
/* .btn-sm 的 background:card 写在 .btn-primary 之后，同特异性会盖掉主按钮的绿底，
   这里提到 0,3,0 把「标记完成」还原成实心 */
.memo-ops .btn-sm.btn-primary {
  background: var(--pine-700);
  border-color: var(--pine-700);
  color: #fff;
}
.memo-ops .btn-sm.btn-primary:hover {
  background: var(--pine-500);
  border-color: var(--pine-500);
  color: #fff;
}
.memo-del:hover { border-color: var(--alert); color: var(--alert); background: #FDF2F0; }
.memo-empty {
  padding: 42px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--r-card);
}

/* ---------- 备忘表单弹窗 ---------- */
.memo-modal-box { width: 660px; max-width: 94vw; max-height: 90vh; overflow: auto; }
.memo-modal-title { font-size: 17px; font-weight: 800; color: var(--ink); margin-bottom: 16px; }
.memo-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.memo-form .span2 { grid-column: 1 / -1; }
.memo-form .form-item { margin-bottom: 12px; }
.req { color: var(--ember); }
/* 必须写到 .form-item .check-row 这一层：`.form-item label` 的 display:block
   特异性 0,1,1，会把 .check-row 单独的 display:flex 盖掉，导致勾选框和文字挤在一起 */
.form-item .check-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 7px;
  cursor: pointer;
}
.form-item .check-row input {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  accent-color: var(--pine-700);
  cursor: pointer;
}
.form-item textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  background: #fff;
  color: var(--ink);
}
.form-item textarea:focus { border-color: var(--pine-500); box-shadow: 0 0 0 3px rgba(62, 123, 88, .15); }
.form-item input:disabled { background: #F5F7F5; color: var(--muted); cursor: not-allowed; }
.seal-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.memo-form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ---------- 备忘录窄屏 ---------- */
@media (max-width: 820px) {
  .chooser { padding: 30px 14px 48px; }
  .chooser-cards { gap: 12px; }
  .chooser-card { min-height: 0; padding: 20px 18px 16px; }
  .memo-card { flex-direction: column; gap: 10px; }
  .memo-card-side {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }
  .memo-ops { justify-content: flex-end; margin-top: 0; }
}
@media (max-width: 640px) {
  .chooser-cards { grid-template-columns: minmax(0, 1fr); }
  .chooser-head h2 { font-size: 17px; }
  .chooser-head p { font-size: 12px; }
  .module-switch { padding: 4px 9px; font-size: 12px; }
  .memo-wrap { padding: 14px 10px 48px; }
  .memo-head { align-items: stretch; }
  .memo-filters { padding: 8px 10px; gap: 6px 16px; }
  .filter-label { min-width: 26px; font-size: 11.5px; }
  .chip { padding: 5px 11px; font-size: 12.5px; }
  .memo-head-actions { width: 100%; }
  .memo-search { flex: 1; width: auto; min-width: 0; }
  .memo-form { grid-template-columns: minmax(0, 1fr); }
  .memo-modal-box { padding: 18px; max-height: 92vh; }
  .memo-card { padding: 12px 13px; }
  .memo-card-title b { font-size: 14px; }
}
