/* 常青工作台：白为主，黑和蓝为辅，红只用于逾期和扣款 */
:root {
  --bg: #ffffff; --bg-2: #f6f7f9; --panel: #ffffff; --line: #e7e9ee; --line-2: #d8dce4;
  --ink: #0d0f14; --ink-2: #3a3f4b; --muted: #7a8090;
  --blue: #2a55d4; --blue-2: #1f43b0; --blue-soft: #edf2ff; --red: #d6372b; --red-soft: #fff0ee; --green: #1f8a4c; --green-soft: #eaf7ef; --amber: #b7791f; --amber-soft: #fff7e6;
  --r: 12px; --r-lg: 18px; --shadow: 0 18px 48px rgba(16, 24, 40, .10); --shadow-sm: 0 2px 8px rgba(16, 24, 40, .06);
  --ease: cubic-bezier(.22, 1, .36, 1); --spring: cubic-bezier(.34, 1.56, .64, 1);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; line-height: 1.6; color: var(--ink); background: var(--bg-2); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
.ic { width: 18px; height: 18px; fill: currentColor; flex: none; }
.ic-sm { width: 15px; height: 15px; }
[hidden] { display: none !important; }

/* ---------- 动效基础 ---------- */
@keyframes enter { from { opacity: 0; transform: translateY(14px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes leave { to { opacity: 0; transform: translateY(-10px); filter: blur(4px); } }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes unpop { to { opacity: 0; transform: scale(.96) translateY(8px); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes unfade { to { opacity: 0; } }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideOut { to { transform: translateX(48px); opacity: 0; } }
@keyframes shimmer { from { background-position: -400px 0; } to { background-position: 400px 0; } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.enter { animation: enter .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
.leaving { animation: leave .22s ease-in forwards; pointer-events: none; }
::view-transition-old(main) { animation: leave .2s ease-in both; }
::view-transition-new(main) { animation: enter .45s var(--ease) both; }
::view-transition-group(*) { animation-duration: .42s; animation-timing-function: var(--ease); }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; cursor: pointer; white-space: nowrap; font-weight: 600; font-size: 13.5px;
  transition: transform .3s var(--spring), background-color .2s, border-color .2s, color .2s, box-shadow .2s; }
.btn:hover { transform: scale(1.03); border-color: var(--ink-2); }
.btn:active { transform: scale(.95); transition-duration: .1s; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #22262f; }
.btn.blue { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.blue:hover { background: var(--blue-2); }
.btn.danger { color: var(--red); border-color: #f1c3be; }
.btn.danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { width: 36px; padding: 0; }
.btn.busy { pointer-events: none; opacity: .7; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.input, select.input, textarea.input { height: 38px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; outline: none; transition: border-color .2s, box-shadow .2s; width: 100%; }
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(42, 85, 212, .12); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.span2 { grid-column: span 2; }
.hint { font-size: 12.5px; color: var(--muted); }
.err-shake { animation: shake .4s; }

/* ---------- 登录 ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 80% -10%, #e9efff, transparent 60%), var(--bg-2); }
.login-card { width: min(400px, 100%); background: #fff; border-radius: 22px; box-shadow: var(--shadow); padding: 36px 32px; animation: pop .6s var(--ease) both; }
.login-card h1 { margin: 14px 0 4px; font-size: 24px; letter-spacing: -.01em; }
.login-card p { margin: 0 0 24px; color: var(--muted); }
.login-card form { display: grid; gap: 14px; }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; }

/* ---------- 外框 ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.shell > div { min-width: 0; }
.side { position: sticky; top: 0; height: 100vh; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px; z-index: 30; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.side-brand b { font-size: 15px; }
.side-brand small { display: block; color: var(--muted); font-size: 12px; line-height: 1.2; }
.nav { display: flex; flex-direction: column; gap: 2px; position: relative; }
.nav a { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 600; transition: color .2s, transform .3s var(--spring); }
.nav a:hover { color: var(--ink); transform: translateX(2px); }
.nav a.active { color: var(--blue); }
.nav a .badge { margin-left: auto; }
.nav-ink { position: absolute; left: 0; right: 0; height: 40px; border-radius: 10px; background: var(--blue-soft); transition: transform .45s var(--spring), opacity .2s; z-index: 0; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; font-weight: 700; flex: none; }
.side-foot div { min-width: 0; flex: 1; }
.side-foot b { display: block; font-size: 13.5px; }
.side-foot small { color: var(--muted); }
.main { min-width: 0; padding: 28px 32px 60px; view-transition-name: main; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 24px; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- 卡片 ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.card h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; transition: transform .35s var(--spring), box-shadow .3s, border-color .3s; cursor: default; }
a.stat, .stat.link { cursor: pointer; color: inherit; }
a.stat:hover, .stat.link:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-2); }
.stat small { color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat b { display: block; font-size: 28px; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat.red b { color: var(--red); }
.stat.blue b { color: var(--blue); }
.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }

/* ---------- 表格 ---------- */
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: auto; box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 700; background: #fbfbfc; position: sticky; top: 0; z-index: 1; }
td.wrap { white-space: normal; min-width: 200px; }
tbody tr { transition: background-color .15s; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #f7f9ff; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty .ic { width: 32px; height: 32px; opacity: .4; display: block; margin: 0 auto 8px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 4px; color: var(--muted); }

/* ---------- 标签 ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--bg-2); color: var(--ink-2); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.dark { background: var(--ink); color: #fff; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: #fff; cursor: pointer; font-weight: 600; font-size: 13px; transition: all .25s var(--spring); }
.chip:hover { transform: scale(1.04); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.red-text { color: var(--red); font-weight: 700; }
.muted { color: var(--muted); }

/* ---------- 抽屉和弹窗 ---------- */
.overlay { position: fixed; inset: 0; background: rgba(13, 15, 20, .32); z-index: 80; animation: fade .25s ease both; backdrop-filter: blur(2px); }
.overlay.closing { animation: unfade .22s ease forwards; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100%); background: #fff; z-index: 90; box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slideIn .42s var(--ease) both; }
.drawer.closing { animation: slideOut .24s ease-in forwards; }
.drawer-head { padding: 20px 24px 14px; border-bottom: 1px solid var(--line); }
.drawer-head .row { display: flex; align-items: center; gap: 10px; }
.drawer-head h3 { margin: 6px 0 0; font-size: 19px; line-height: 1.4; }
.drawer-body { flex: 1; overflow: auto; padding: 18px 24px 40px; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 24px; border-bottom: 1px solid var(--line); background: #fbfbfc; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 20px; margin-bottom: 18px; }
.kv div small { display: block; color: var(--muted); font-size: 12px; }
.kv div b { font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; position: relative; }
.tabs button { border: 0; background: none; padding: 10px 12px; font-weight: 700; color: var(--muted); cursor: pointer; position: relative; transition: color .2s; }
.tabs button.on { color: var(--ink); }
.tabs .tab-ink { position: absolute; bottom: -1px; height: 2px; background: var(--blue); transition: transform .4s var(--spring), width .4s var(--spring); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 14px 1fr; gap: 10px; padding: 8px 0; }
.timeline li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); margin-top: 7px; justify-self: center; }
.timeline li:first-child::before { background: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.timeline small { color: var(--muted); }
.modal { position: fixed; z-index: 100; left: 50%; top: 50%; width: min(560px, calc(100% - 32px)); max-height: calc(100% - 40px); overflow: auto; transform: translate(-50%, -50%); background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 22px 24px; animation: pop .38s var(--ease) both; }
.modal-in { animation: pop .38s var(--ease) both; }
.modal.closing { animation: unpop .2s ease-in forwards; }
.modal h3 { margin: 0 0 16px; font-size: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-wrap { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; pointer-events: none; }
.modal-wrap > .modal { position: relative; left: auto; top: auto; transform: none; pointer-events: auto; }

/* ---------- 提示 ---------- */
.toasts { position: fixed; z-index: 200; left: 50%; bottom: 28px; transform: translateX(-50%); display: grid; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; animation: pop .35s var(--spring) both; display: flex; align-items: center; gap: 8px; }
.toast.err { background: var(--red); }
.toast.out { animation: unpop .25s ease-in forwards; }
.banner { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--amber-soft); color: #7a4f10; margin-bottom: 14px; font-weight: 600; }
.banner.red { background: var(--red-soft); color: var(--red); }
.banner.blue { background: var(--blue-soft); color: var(--blue); }
.skel { height: 14px; border-radius: 6px; background: linear-gradient(90deg, #eef0f4 25%, #f7f8fa 50%, #eef0f4 75%); background-size: 800px 100%; animation: shimmer 1.2s linear infinite; }

/* ---------- 图表 ---------- */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 90px; gap: 10px; align-items: center; }
.bar-track { height: 10px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--blue); border-radius: 999px; transform-origin: left; animation: grow .9s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }
.bar-fill.red { background: var(--red); }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.chart { width: 100%; height: auto; }
.chart .col { transform-box: fill-box; transform-origin: bottom; animation: rise .8s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms); }
@keyframes rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .4s var(--ease); box-shadow: var(--shadow); }
  body.nav-open .side { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(13, 15, 20, .3); z-index: 20; animation: fade .2s; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 10; background: rgba(255, 255, 255, .9); backdrop-filter: blur(10px); padding: 10px 16px; border-bottom: 1px solid var(--line); }
  .topbar b { font-size: 15px; }
  .main { padding: 18px 16px 60px; }
  .two { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .kv { grid-template-columns: 1fr 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
  .stat b { font-size: 22px; }
  .page-head h2 { font-size: 20px; }
  .drawer-head, .drawer-body, .drawer-actions { padding-left: 16px; padding-right: 16px; }
  .bar-row { grid-template-columns: 80px 1fr 70px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
