:root {
  --brand: #2f6df6;
  --brand-dark: #1e4fd0;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #1f2430;
  --muted: #7a8194;
  --border: #e6e9f0;
  --ok: #21a366;
  --warn: #e8890c;
  --danger: #e14b4b;
  --todo: #8a93a6;
  --doing: #2f6df6;
  --done: #21a366;
  --delayed: #e14b4b;
  --shadow: 0 4px 20px rgba(31, 45, 90, 0.08);
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: var(--brand); text-decoration: none; }
.hidden { display: none !important; }

/* ---------- 登录/注册 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2f6df6 0%, #6a4bf0 100%);
  padding: 20px;
}
.auth-card {
  background: var(--panel);
  width: 100%; max-width: 400px;
  border-radius: 16px; padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.auth-card h1 { font-size: 22px; text-align: center; margin-bottom: 4px; }
.auth-logo { display: block; width: 72px; height: 72px; object-fit: contain; background: #fff; border-radius: 14px; padding: 8px; margin: 0 auto 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: #fafbfd; transition: border .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); background: #fff; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border: none; border-radius: 8px;
  background: var(--brand); color: #fff; font-weight: 600; transition: background .15s;
}
.btn:hover { background: var(--brand-dark); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--border); }
.btn.ghost:hover { background: #f0f4ff; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #c53a3a; }
.btn.ok { background: var(--ok); }
.auth-toggle { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.auth-msg { font-size: 13px; padding: 8px 12px; border-radius: 8px; margin-bottom: 14px; }
.auth-msg.err { background: #fde8e8; color: var(--danger); }
.auth-msg.ok { background: #e6f6ee; color: var(--ok); }

/* ---------- 应用框架 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #141b2d; color: #cfd6e6; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { padding: 18px 20px; font-size: 16px; font-weight: 700; color: #fff; letter-spacing: .3px; display: flex; align-items: center; gap: 10px; }
.sidebar .logo img.logo-img { width: 38px; height: 38px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.sidebar .logo span { color: #6fa0ff; }
.nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 11px 22px;
  color: #aab3c9; font-size: 14px; border-left: 3px solid transparent; cursor: pointer;
}
.nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav a.active { background: rgba(47,109,246,.18); color: #fff; border-left-color: var(--brand); }
.nav a .badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 10px; }
.sidebar .foot { padding: 16px 22px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #7a8398; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-size: 17px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.month-picker { display: flex; align-items: center; gap: 12px; }
.month-picker input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; }
.month-picker > span { white-space: nowrap; }
.icon-btn {
  position: relative; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
  background: #fff; display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.icon-btn:hover { background: #f0f4ff; }
.icon-btn .dot { position: absolute; top: 6px; right: 8px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; }
.user-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.user-chip:hover { background: #f0f4ff; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }
.role-tag { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: #eef2fb; color: var(--brand); }

.content { padding: 24px; flex: 1; }

/* ---------- 通用卡片/表格 ---------- */
.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px,1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { background: var(--panel); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card .num { font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat-card .num.ok { color: var(--ok); } .stat-card .num.warn { color: var(--warn); } .stat-card .num.danger { color: var(--danger); }

.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.panel h3 { font-size: 15px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.panel .hd { display: flex; align-items: center; margin-bottom: 14px; gap: 12px; }
.panel .hd h3 { margin: 0; } .panel .hd .spacer { flex: 1; }
.panel .hd > label, .panel .hd > .muted-sm { white-space: nowrap; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 600; background: #fafbfd; }
tr:hover td { background: #fafbff; }

.tag { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 20px; }
.tag.pending { background: #fff4e0; color: var(--warn); }
.tag.active { background: #e6f6ee; color: var(--ok); }
.tag.disabled { background: #f0f1f4; color: var(--muted); }
.tag.role-employee { background: #eef2fb; color: #5566aa; }
.tag.role-manager { background: #e8f0ff; color: var(--brand); }
.tag.role-superadmin { background: #f3e8ff; color: #8b3ff0; }

/* ---------- 看板 ---------- */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; align-items: start; }
.board-col { background: #eef1f7; border-radius: var(--radius); padding: 12px; min-height: 200px; }
.board-col .col-hd { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 12px; font-size: 14px; }
.board-col .col-hd .count { margin-left: auto; background: #fff; color: var(--muted); padding: 0 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.col-dot { width: 9px; height: 9px; border-radius: 50%; }
.dot-todo { background: var(--todo); } .dot-doing { background: var(--doing); } .dot-done { background: var(--done); } .dot-delayed { background: var(--delayed); }

.task-card { background: #fff; border-radius: 10px; padding: 13px; margin-bottom: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.05); cursor: pointer; border-left: 3px solid var(--todo); transition: transform .1s, box-shadow .1s; }
.task-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.1); }
.task-card.p-high { border-left-color: var(--danger); }
.task-card.p-medium { border-left-color: var(--warn); }
.task-card.p-low { border-left-color: var(--todo); }
.task-card .t-title { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.task-card .t-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.task-card .due { display: inline-flex; align-items: center; gap: 3px; }
.task-card .due.over { color: var(--danger); font-weight: 600; }
.progress { height: 7px; background: #eef1f7; border-radius: 6px; overflow: hidden; margin: 10px 0 8px; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 6px; }
.assignees { display: flex; gap: -6px; margin-top: 8px; }
.mini-avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; margin-right: -6px; border: 2px solid #fff; }
.prio-badge { font-size: 11px; padding: 1px 7px; border-radius: 5px; }
.prio-badge.high { background: #fde8e8; color: var(--danger); }
.prio-badge.medium { background: #fff4e0; color: var(--warn); }
.prio-badge.low { background: #eef1f7; color: var(--muted); }

/* ---------- 模态框 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(20,27,45,.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal .m-hd { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal .m-hd h3 { font-size: 16px; } .modal .m-hd .spacer { flex: 1; }
.modal .m-hd .close { font-size: 22px; color: var(--muted); background: none; border: none; }
.modal .m-body { padding: 20px 22px; }
.modal .m-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chk-list { display: flex; flex-wrap: wrap; gap: 8px; max-height: 140px; overflow-y: auto; padding: 4px; border: 1px solid var(--border); border-radius: 8px; }
.chk-item { display: flex; align-items: center; gap: 5px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 20px; cursor: pointer; font-size: 13px; }
.chk-item.sel { background: #eef4ff; border-color: var(--brand); color: var(--brand); }

/* 通知面板 */
.notif-panel { position: absolute; top: 54px; right: 60px; width: 320px; background: #fff; border-radius: 12px; box-shadow: var(--shadow); z-index: 50; max-height: 400px; overflow-y: auto; border: 1px solid var(--border); }
.notif-panel .n-item { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.notif-panel .n-item.unread { background: #f0f6ff; }
.notif-panel .n-item .time { color: var(--muted); font-size: 11px; margin-top: 4px; }
.notif-panel .empty { padding: 30px; text-align: center; color: var(--muted); }

.user-menu { position: absolute; top: 54px; right: 20px; background: #fff; border-radius: 10px; box-shadow: var(--shadow); z-index: 50; border: 1px solid var(--border); overflow: hidden; min-width: 160px; }
.user-menu a { display: block; padding: 11px 16px; color: var(--text); font-size: 14px; }
.user-menu a:hover { background: #f0f4ff; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state .big { font-size: 40px; margin-bottom: 10px; }

.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: #141b2d; color: #fff; padding: 12px 22px; border-radius: 10px; z-index: 200; box-shadow: 0 10px 30px rgba(0,0,0,.3); font-size: 14px; }
.toast.err { background: var(--danger); } .toast.ok { background: var(--ok); }

.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ---------- 移动端抽屉与响应式 ---------- */
.menu-btn { display: none; }
.nav-backdrop { position: fixed; inset: 0; background: rgba(20,27,45,.45); z-index: 55; opacity: 0; visibility: hidden; transition: opacity .25s ease; }
.nav-backdrop.show { opacity: 1; visibility: visible; }

@media (max-width: 900px) {
  .board { grid-template-columns: 1fr 1fr; }
  .charts-row { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .app { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 240px; z-index: 60;
    transform: translateX(-100%); transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .menu-btn { display: flex; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar .page-title { font-size: 15px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .month-picker { gap: 6px; }
  .month-picker input { padding: 6px 8px; }
  .content { padding: 14px; }
  .board { grid-template-columns: 1fr; }
  .cards-row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .rev-grid { grid-template-columns: 1fr 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .modal { max-width: 100%; margin: 0 10px; }
  .notif-panel, .user-menu { right: 10px; }
  /* 表格横向滚动，避免移动端挤压换行 */
  table { display: block; width: 100%; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  th, td { white-space: nowrap; }
}

@media (max-width: 560px) {
  .topbar .page-title { max-width: 42vw; }
  .content { padding: 12px; }
  .rev-grid { grid-template-columns: 1fr; }
  .cards-row { grid-template-columns: 1fr 1fr; }
  .stat-card .num { font-size: 24px; }
  .proj-hero { flex-direction: column; align-items: flex-start; gap: 10px; }
  .topbar { gap: 8px; }
  .user-chip .role-tag, .user-chip #userName { display: none; }
  .user-chip { padding: 4px; }
}

/* ---------- 月度经营看板（临时排版） ---------- */
.proj-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.proj-hero-left { display: flex; align-items: center; gap: 16px; }
.proj-logo { width: 56px; height: 56px; object-fit: contain; background:#fff; border-radius: 12px; padding: 6px; box-shadow: var(--shadow); }
.proj-hero h2 { font-size: 20px; }
.proj-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 12px; }
.section-title > span:first-child { font-size: 16px; font-weight: 700; }
.muted-sm { color: var(--muted); font-size: 12px; }
.rev-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) { .rev-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .rev-grid { grid-template-columns: repeat(2, 1fr); } }
.rev-card { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; }
.rev-card .rev-hd { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.rev-card .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.rev-actual { font-size: 30px; font-weight: 800; line-height: 1.1; margin-top: 4px; }
.rev-actual .unit { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.rev-sub { font-size: 12px; color: var(--muted); }
.rev-mom { font-size: 12px; color: var(--muted); }
.rev-vis { font-size: 12px; color: var(--muted); margin-top: 2px; }
.rev-total { background: linear-gradient(135deg, #2f6df6 0%, #1e4fd0 100%); color: #fff; }
.rev-total .rev-hd, .rev-total .rev-sub, .rev-total .rev-mom, .rev-total .rev-vis { color: rgba(255,255,255,.85); }
.rev-total .rev-sub b, .rev-total .rev-vis b { color: #fff; }
.data-table { width: 100%; border-collapse: collapse; }
.cell-prog { display: flex; align-items: center; gap: 8px; }
.cell-prog .pct { font-size: 12px; color: var(--muted); width: 34px; text-align: right; flex: none; }

/* ---------- 任务表单 / 重点任务 ---------- */
.key-badge { display: inline-block; background: #fff4e0; color: var(--warn); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; margin-right: 6px; vertical-align: middle; }
.ro-text { padding: 9px 12px; background: #fafbfd; border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 13px; }
.key-field { background: #fffaf2; border: 1px solid #f3e2c7; border-radius: 8px; padding: 10px 12px; }
.key-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.key-label input { width: 15px; height: 15px; }

/* ---------- 营收填报 / 每日录入 ---------- */
.inp { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: #fff; color: var(--text); max-width: 100%; }
.inp:focus { outline: none; border-color: var(--brand); }
.inp.num { text-align: right; }
.rev-note { background: #f6f9ff; border: 1px solid #e3ecff; border-radius: 8px; padding: 10px 14px; color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.dc-log { font-family: "SF Mono", "Fira Code", Consolas, monospace; font-size: 12px; line-height: 1.6; background: #f7f8fb; border: 1px solid var(--border); color: #334; padding: 14px 16px; border-radius: var(--radius); max-height: 360px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; }
.file-size, .file-time { color: var(--muted); font-size: 12px; }
