:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #fafbfe;
  --ink: #1a2236;
  --ink-2: #47546e;
  --muted: #8794ac;
  --line: #e7ecf4;
  --line-strong: #d8e0ec;
  --primary: #3f7508;
  --primary-soft: #f0f8e2;
  --violet: #83cb0f;
  --green: #0ea371;
  --green-soft: #e6f7f1;
  --amber: #d97706;
  --amber-soft: #fef4e5;
  --blue: #1b7a5a;
  --blue-soft: #e6f7f1;
  --red: #dc2626;
  --red-soft: #fdecec;
  --sidebar-bg: #151d31;
  --sidebar-ink: #aab4cc;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(20, 30, 55, .06);
  --shadow: 0 6px 24px rgba(20, 30, 55, .08);
  --shadow-lg: 0 24px 60px rgba(16, 24, 45, .18);
  --sidebar-w: 232px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd8e6; border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b6c2d6; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ================= 登录页 ================= */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(131, 203, 15, 0.26), transparent 55%),
    radial-gradient(900px 480px at 92% 8%, rgba(78, 138, 10, 0.36), transparent 52%),
    linear-gradient(160deg, #0b1226 0%, #16213d 100%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(255, 255, 255, .97);
  border-radius: 20px;
  padding: 38px 34px 32px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(140deg, #0b1226, #2f6b0b);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 24px;
  margin-bottom: 18px;
  box-shadow: 0 8px 20px rgba(11, 18, 38, 0.38);
}

.login-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: .3px; }
.login-card p.sub { margin: 0 0 26px; color: var(--muted); font-size: 13px; }
.login-hint {
  margin-top: 20px;
  padding: 12px 14px;
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.8;
}
.login-hint b { color: var(--primary); }
.login-mobile-links {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  gap: 18px;
  font-size: 12.5px;
}
.login-mobile-links a {
  color: var(--primary);
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--primary-soft);
}
.login-mobile-links a:hover { text-decoration: underline; }

/* ================= 外壳 ================= */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sidebar-brand .mark {
  width: 34px; height: 34px;
  background: transparent;
  display: grid; place-items: center; color: #fff; font-size: 16px; flex: none;
}
.sidebar-brand .mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sidebar-brand .title { color: #fff; font-weight: 600; font-size: 13.5px; line-height: 1.35; }
.sidebar-brand .desc { font-size: 11px; color: #6f7b96; }

.nav { padding: 14px 10px; overflow-y: auto; flex: 1; }
.nav-group-label {
  font-size: 11px; color: #5d6880; padding: 14px 12px 6px; letter-spacing: 1px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; margin-bottom: 2px;
  color: var(--sidebar-ink); font-size: 13.5px; cursor: pointer;
  transition: background .16s, color .16s;
}
.nav-item .ico { width: 18px; text-align: center; opacity: .85; font-size: 14px; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, #83cb0f, #a3e635); color: #0b1226; font-weight: 600; box-shadow: 0 4px 14px rgba(131, 203, 15, .28); }
.nav-item .badge-count {
  margin-left: auto; background: rgba(255, 255, 255, .14); color: #fff;
  border-radius: 20px; padding: 0 7px; font-size: 11px; min-width: 20px; text-align: center;
}

.sidebar-user {
  border-top: 1px solid rgba(255, 255, 255, .07);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: linear-gradient(140deg, #0b1226, #4e8a0a);
  color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 600;
}
.sidebar-user .meta { min-width: 0; flex: 1; }
.sidebar-user .name { color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .role { font-size: 11px; color: #6f7b96; }
.icon-btn {
  background: transparent; border: none; color: var(--sidebar-ink); cursor: pointer;
  padding: 5px; border-radius: 7px; font-size: 15px; line-height: 1;
}
.icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 62px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
  padding: 0 26px;
  position: sticky; top: 0; z-index: 30;
}
.topbar h2 { margin: 0; font-size: 17px; font-weight: 600; }
.topbar .crumb { color: var(--muted); font-size: 12.5px; }
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; background: none; border: none; font-size: 19px; cursor: pointer; color: var(--ink); }

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

/* ================= 通用组件 ================= */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .sub { font-size: 12.5px; color: var(--muted); }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 15px;
  border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  font-size: 13.5px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: #c3cee0; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: #83cb0f; border-color: #83cb0f; color: #0b1226; font-weight: 600; box-shadow: 0 3px 10px rgba(131, 203, 15, .3); }
.btn.primary:hover { background: #95d92a; border-color: #95d92a; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--muted); }

input, select, textarea {
  font-family: inherit; font-size: 13.5px; color: var(--ink);
  height: 36px; padding: 0 11px;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface); outline: none; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 9px 11px; resize: vertical; min-height: 76px; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(131, 203, 15, .2); }
input::placeholder, textarea::placeholder { color: #b3bccd; }
select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%238794ac' d='M6 8.5 2 4.5h8z'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
input[type="date"] { cursor: pointer; }

.search-wrap { position: relative; }
.search-wrap input { padding-left: 32px; }
.search-wrap::before { content: "🔍"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: .55; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px;
  padding: 11px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: #f8fafd; }
table.data tbody tr.clickable { cursor: pointer; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .actions { text-align: right; white-space: nowrap; }
table.data .actions .btn { margin-left: 4px; }

.empty { padding: 46px 20px; text-align: center; color: var(--muted); }
.empty .icon { font-size: 30px; opacity: .35; margin-bottom: 8px; }

.pager { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.pager .spacer { flex: 1; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge.gray { background: #eef1f6; color: #5b6880; }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.violet { background: #f1f9e4; color: var(--primary); }
.badge.indigo { background: var(--primary-soft); color: var(--primary); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; color: var(--ink-2); }

.stat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat .label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 25px; font-weight: 650; margin-top: 6px; letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat .trend { font-size: 12px; margin-top: 4px; color: var(--muted); }
.stat .trend.up { color: var(--green); }
.stat .trend.down { color: var(--red); }
.stat .accent { position: absolute; right: -18px; top: -18px; width: 76px; height: 76px; border-radius: 50%; opacity: .08; background: var(--primary); }
.stat.g .accent { background: var(--green); }
.stat.a .accent { background: var(--amber); }
.stat.b .accent { background: var(--blue); }
.stat.v .accent { background: var(--violet); }

.progress { height: 7px; background: #edf1f7; border-radius: 20px; overflow: hidden; min-width: 90px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--violet)); border-radius: 20px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 9px 15px; font-size: 13.5px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap; background: none; border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 9px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); }

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

.chart-box { width: 100%; overflow: hidden; }
.chart-box svg { display: block; width: 100%; height: auto; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 6px; }

.rank-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.rank-row:last-child { border-bottom: none; }
.rank-row .idx { width: 18px; color: var(--muted); font-size: 12px; text-align: center; }
.rank-row .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-row .bar { width: 110px; height: 6px; background: #eef1f7; border-radius: 6px; overflow: hidden; }
.rank-row .bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--violet)); }
.rank-row .val { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 12.5px; min-width: 78px; text-align: right; }

/* ================= 弹窗 ================= */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 45, .5);
  display: grid; place-items: center; z-index: 100; padding: 22px;
  backdrop-filter: blur(2px);
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: pop .18s ease;
}
.modal.wide { max-width: 860px; }
.modal.slim { max-width: 420px; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head { padding: 17px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 15.5px; font-weight: 600; flex: 1; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 16px 16px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-error { background: var(--red-soft); color: var(--red); padding: 9px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 14px; }

/* ================= 提示条 ================= */
.toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: #1f2a41; color: #fff; padding: 11px 16px; border-radius: 10px;
  font-size: 13.5px; box-shadow: var(--shadow); min-width: 200px; max-width: 380px;
  animation: slide .2s ease; display: flex; align-items: center; gap: 9px;
}
@keyframes slide { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
.toast.success { background: #127a58; }
.toast.error { background: #c02626; }
.toast.warning { background: #b45309; }

/* ================= 排期看板 ================= */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; }
.board-col { min-width: 190px; flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.board-col > .col-head { padding: 11px 13px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.board-col .col-head .nm { font-size: 13.5px; font-weight: 600; }
.board-col .col-head .role { font-size: 11.5px; color: var(--muted); }
.board-col .col-head .load { margin-top: 6px; font-size: 11.5px; color: var(--ink-2); }
.board-col .items { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.entry {
  border-left: 3px solid var(--primary); background: var(--surface-2);
  border-radius: 8px; padding: 8px 10px; font-size: 12.5px; cursor: pointer;
  transition: box-shadow .15s, transform .1s;
}
.entry:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.entry .t { font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.entry .m { color: var(--muted); font-size: 11.5px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.entry.conflict { border-left-color: var(--red); background: var(--red-soft); }
.entry.leave { border-left-color: var(--muted); background: #f3f5f9; opacity: .75; }

.timeline { display: flex; flex-direction: column; gap: 2px; }
.tl-item { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.tl-item:last-child { border-bottom: none; }
.tl-item .tl-date { width: 92px; flex: none; color: var(--muted); font-size: 12.5px; }
.tl-item .tl-main { flex: 1; min-width: 0; }
.tl-item .tl-sub { color: var(--muted); font-size: 12.5px; }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 9px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 10px; align-items: center; font-size: 13.5px; }
.list-plain li:last-child { border-bottom: none; }

.seg { display: inline-flex; background: #eef1f7; border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: none; background: transparent; padding: 5px 13px; border-radius: 7px;
  font-size: 12.5px; color: var(--ink-2); cursor: pointer;
}
.seg button.active { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: var(--shadow-sm); }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  padding: 4px 11px; border-radius: 20px; font-size: 12.5px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.money { font-variant-numeric: tabular-nums; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

.loading { padding: 46px; text-align: center; color: var(--muted); }
.loading::after {
  content: ""; display: inline-block; width: 15px; height: 15px; margin-left: 8px;
  border: 2px solid var(--line-strong); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.back-link { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; cursor: pointer; margin-bottom: 12px; }
.back-link:hover { color: var(--primary); }

/* ================= 响应式 ================= */
@media (max-width: 1180px) {
  .grid.cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.side { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .grid.cols-3, .grid.cols-4, .grid.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 18px 14px 50px; }
  .topbar { padding: 0 14px; }
}
@media (max-width: 560px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-5 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ================= Client Portal ================= */
.client-greeting { display: flex; align-items: baseline; gap: 2px 4px; flex-wrap: wrap; margin-bottom: 4px; }
.client-greeting h2 { margin: 0; font-size: 18px; line-height: 1.4; }
.client-greeting-contact { color: var(--ink-2); font-size: 12.5px; line-height: 1.6; }
.client-greeting-contact a { color: var(--primary); font-weight: 600; }
.client-greeting-contact a:hover { text-decoration: underline; }

