:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #e3e8ef;
  --text: #17202b;
  --muted: #6b7787;
  --brand: #1f5fd0;
  --brand-soft: #e8f0fe;
  --green: #0e9f6e;
  --green-soft: #e3f7ef;
  --red: #d64545;
  --red-soft: #fdecec;
  --amber: #b7791f;
  --amber-soft: #fdf5e6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

/* ---------------- 登录 ---------------- */
.auth-wrap {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #dce8ff 0%, #f4f6f9 55%);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--panel);
  border-radius: 20px; padding: 32px 26px; box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.brand-mark {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, #1f5fd0, #3b8bff); color: #fff;
  font-weight: 700; font-size: 20px; margin-bottom: 16px;
}
.auth-card h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: -.3px; }
.auth-card p.sub { margin: 0 0 24px; color: var(--muted); 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: 11px 13px; border: 1px solid var(--line);
  border-radius: 10px; background: #fbfcfe; outline: none; transition: .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(31, 95, 208, .1);
}
.field textarea { min-height: 84px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
  background: var(--brand); color: #fff; transition: .15s; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn.ghost { background: #eef2f7; color: var(--text); }
.btn.line { background: #fff; border: 1px solid var(--line); color: var(--text); }
.btn.danger { background: var(--red); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.wide { width: 100%; padding: 13px; font-size: 15px; }
.btn:disabled { opacity: .55; }

/* ---------------- 壳 ---------------- */
.app { display: none; min-height: 100dvh; }
.app.on { display: block; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px; display: flex; align-items: center; gap: 12px;
}
.topbar .logo {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #1f5fd0, #3b8bff); color: #fff; font-weight: 700; font-size: 13px;
}
.topbar .title { font-weight: 700; font-size: 15px; letter-spacing: -.2px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12px; color: var(--muted); text-align: right; line-height: 1.3; }
.topbar .who b { display: block; color: var(--text); font-size: 13px; font-weight: 600; }

.main { padding: 16px; max-width: 1180px; margin: 0 auto 78px; }
.app.admin-mode .main, .app.staff-mode .main { }

/* ---------------- 通用块 ---------------- */
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.page-head h2 { font-size: 19px; margin: 0; letter-spacing: -.3px; }
.page-head .spacer { flex: 1; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.card h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); font-weight: 600; letter-spacing: .2px; }

.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; align-items: start; }
.grid4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.stat .k { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat .v { font-size: 21px; font-weight: 700; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.stat .v.blue { color: var(--brand); }
.stat .v.green { color: var(--green); }
.stat .v.red { color: var(--red); }
.stat .h { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ---------------- 列表 ---------------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.row-item {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; box-shadow: var(--shadow); cursor: pointer; transition: .15s;
}
.row-item:active { background: #f8fafd; }
.row-item .l1 { display: flex; align-items: baseline; gap: 8px; }
.row-item .l1 .n { font-weight: 600; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .l2 { font-size: 12.5px; color: var(--muted); margin-top: 5px; display: flex; gap: 10px; flex-wrap: wrap; }
.row-item .l3 { display: flex; gap: 14px; margin-top: 8px; font-size: 13px; flex-wrap: wrap; }
.row-item .l3 span b { font-weight: 600; font-variant-numeric: tabular-nums; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11.5px;
  font-weight: 600; white-space: nowrap; background: #eef2f7; color: var(--muted);
}
.tag.blue { background: var(--brand-soft); color: var(--brand); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; font-size: 13.5px; }
.empty .ico { font-size: 28px; display: block; margin-bottom: 8px; opacity: .45; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- 底部导航 ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px 2px; color: var(--muted); font-size: 10.5px; border-radius: 10px;
}
.tabbar a .ti { font-size: 18px; line-height: 1; }
.tabbar a.on { color: var(--brand); }
.tabbar a.on .ti { transform: translateY(-1px); }

/* ---------------- 弹窗 ---------------- */
dialog {
  border: 0; padding: 0; border-radius: 18px; width: min(520px, calc(100vw - 28px));
  max-height: calc(100dvh - 60px); box-shadow: 0 24px 60px rgba(16, 24, 40, .28);
  background: var(--panel); overflow: hidden;
}
dialog::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
.dlg-head { display: flex; align-items: center; padding: 16px 18px 10px; }
.dlg-head h3 { margin: 0; font-size: 16px; flex: 1; }
.dlg-body { padding: 4px 18px 8px; overflow-y: auto; max-height: 62dvh; }
.dlg-foot { padding: 12px 18px calc(16px + env(safe-area-inset-bottom)); display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line); }
.x { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); font-size: 18px; }

/* ---------------- 提示 ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 12px);
  background: #17202b; color: #fff; padding: 10px 18px; border-radius: 22px;
  font-size: 13.5px; opacity: 0; pointer-events: none; transition: .22s; z-index: 100; max-width: 80vw;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--red); }

/* ---------------- 详情 ---------------- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; font-size: 13.5px; }
.detail-grid .k { color: var(--muted); font-size: 12px; }
.detail-grid .v { font-weight: 600; }
.section-title { font-size: 13px; color: var(--muted); font-weight: 600; margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.section-title .spacer { flex: 1; }

.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 14px; }
.tl-item::before { content: ''; position: absolute; left: -17px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.tl-item .t { font-size: 13.5px; font-weight: 600; }
.tl-item .d { font-size: 12px; color: var(--muted); }

/* ---------------- 桌面 ---------------- */
.sidebar { display: none; }
@media (min-width: 900px) {
  .app { display: none; }
  .app.on { display: flex; }
  .sidebar {
    display: flex; flex-direction: column; width: 216px; flex: 0 0 216px;
    background: #fff; border-right: 1px solid var(--line);
    position: sticky; top: 0; height: 100dvh; padding: 18px 12px; gap: 2px;
  }
  .sidebar .logo-row { display: flex; align-items: center; gap: 9px; padding: 0 8px 18px; }
  .sidebar .logo-row .logo {
    width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
    background: linear-gradient(135deg, #1f5fd0, #3b8bff); color: #fff; font-weight: 700; font-size: 13px;
  }
  .sidebar .logo-row b { font-size: 14px; letter-spacing: -.2px; }
  .sidebar a {
    display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 9px;
    color: #45525f; font-size: 13.5px; font-weight: 500;
  }
  .sidebar a .ti { font-size: 15px; width: 18px; text-align: center; }
  .sidebar a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
  .sidebar a:hover:not(.on) { background: #f4f6f9; }
  .sidebar .bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
  .content-col { flex: 1; min-width: 0; }
  .topbar { padding: 12px 26px; }
  .main { margin-bottom: 30px; padding: 22px 26px; }
  .tabbar { display: none; }
  .grid4 { grid-template-columns: repeat(4, 1fr); }
  .modal-wide { width: min(720px, calc(100vw - 40px)); }
}

@media (max-width: 380px) {
  .main { padding: 12px; }
  .stat .v { font-size: 18px; }
}

@media (max-width: 899px) {
  .page-head h2 { display: none; }
  .page-head h2.keep { display: block; }
  .topbar .title { font-size: 16px; }
}

.lead-hero { text-align: center; padding: 8px 0 20px; }
.lead-hero h2 { font-size: 22px; margin: 0 0 8px; letter-spacing: -.4px; }
.lead-hero p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.7; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
