:root {
  --blue: #185FA5; --blue-d: #042C53; --blue-l: #E6F1FB; --blue-b: #B5D4F4;
  --night: #534AB7; --night-l: #EEEDFE; --night-b: #CECBF6;
  --ink: #2C2C2A; --ink2: #5F5E5A; --ink3: #888780; --ink4: #B4B2A9;
  --bg: #F2F4F6; --line: #E4E9EE; --line2: #D8DCE0; --soft: #F7F9FB;
  --ok: #3B6D11; --ok-l: #EAF3DE; --ok-b: #C0DD97;
  --warn: #854F0B; --warn-l: #FAEEDA; --warn-b: #FAC775;
  --err: #A32D2D; --err-l: #FCEBEB; --err-b: #F7C1C1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- 外壳：手机竖排 / 桌面侧栏 ---------- */
.shell {
  display: flex; flex-direction: column; flex: 1;
  width: 100%; max-width: 480px; margin: 0 auto;
  background: #fff; box-shadow: 0 0 0 1px var(--line);
}
.sidebar { display: none; }
.main { display: flex; flex-direction: column; flex: 1; min-width: 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--blue); color: #fff; padding: 7px 14px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20; flex: none; min-height: 56px;
}
.topbar.night { background: var(--night); }
.topbar h1 { flex: 1; text-align: center; font-size: 15px; font-weight: 600; letter-spacing: .3px; }
.topbar .tb-left, .topbar .tb-right { flex: 0 0 76px; display: flex; align-items: center; }
.topbar .tb-right { justify-content: flex-end; }
.topbar .back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; margin-left: -11px; border-radius: 11px;
  cursor: pointer; color: inherit; -webkit-tap-highlight-color: transparent;
  transition: background .15s;
}
.topbar .back svg { display: block; pointer-events: none; }
.topbar .back:active { background: rgba(255, 255, 255, .22); }

.brand { background: #fff; border-radius: 5px; padding: 2px 4px; display: inline-flex; }
.brand img { height: 16px; display: block; }

/* ---------- 主体 ---------- */
.page { flex: 1; padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.page.center { justify-content: center; }

.card { background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.card.white { background: #fff; }
.card > .card-title { font-size: 12.5px; color: var(--ink2); margin-bottom: 10px; }

.hint { font-size: 12px; color: var(--ink3); line-height: 1.6; }
.hint.center { text-align: center; }

.note { border-radius: 8px; padding: 10px 12px; font-size: 12.5px; line-height: 1.6; }
.note.info { background: var(--blue-l); border: 1px solid var(--blue-b); color: var(--blue-d); }
.note.lock { background: var(--warn-l); border: 1px solid var(--warn-b); color: var(--warn); }
.note.err { background: var(--err-l); border: 1px solid var(--err-b); color: var(--err); }
.note.ok { background: var(--ok-l); border: 1px solid var(--ok-b); color: var(--ok); }

/* ---------- 统计块 ---------- */
.stat-row { display: flex; gap: 10px; }
.stat-box { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.stat-box .lb { font-size: 12.5px; color: var(--ink2); }
.stat-box .nb { font-size: 19px; font-weight: 600; color: var(--blue-d); margin-top: 6px; }
.stat-box .nb em { font-style: normal; font-size: 12.5px; font-weight: 400; color: var(--ink2); margin-left: 2px; }

/* ---------- 按钮 ---------- */
.btn {
  display: block; width: 100%; border: none; cursor: pointer; text-align: center;
  background: var(--blue); color: #fff; border-radius: 9px; padding: 13px;
  font-size: 14px; font-weight: 600; font-family: inherit; transition: opacity .15s;
}
.btn:active { opacity: .82; }
.btn.night { background: var(--night); }
.btn.ghost { background: #fff; color: var(--blue); border: 1px solid var(--blue-b); }
.btn.danger { background: #fff; color: var(--err); border: 1px solid var(--err-b); }
.btn.sm { padding: 9px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; }

/* ---------- 表单 ---------- */
.field {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--soft); border: 1px solid var(--line); border-radius: 9px;
  padding: 11px 13px; font-size: 13.5px;
}
.field .k { color: var(--ink2); white-space: nowrap; }
.field input, .field select, .field textarea {
  flex: 1; border: none; background: transparent; font-family: inherit; font-size: 13.5px;
  color: var(--ink); text-align: right; outline: none; min-width: 0;
}
.field textarea { text-align: left; resize: none; height: 52px; }
.field input::placeholder, .field textarea::placeholder { color: var(--ink4); }
.field.calc { background: var(--blue-l); border-color: var(--blue-b); }
.field.calc .v { color: var(--blue-d); font-weight: 600; }
.field.lock { background: #F1EFE8; }
.field.lock .v { color: var(--ink3); }

.field-label { font-size: 12.5px; color: var(--ink2); margin: 2px 0 -4px; }

.opt {
  display: flex; align-items: center; gap: 10px; padding: 13px;
  border: 1px solid var(--line2); border-radius: 9px; font-size: 13.5px; cursor: pointer;
}
.opt.sel { border-color: var(--night); background: var(--night-l); }
.opt .round { width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid var(--ink4); flex: none; }
.opt.sel .round { border: 4.5px solid var(--night); }
.opt b { font-weight: 600; }

/* ---------- 列表 ---------- */
.item { padding: 11px 0; border-bottom: 1px solid #EDEFF2; }
.item:last-child { border-bottom: none; }
.item .row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.item .row2 { font-size: 12px; color: var(--ink2); margin-top: 3px; line-height: 1.55; }
.item .acts { display: flex; gap: 10px; flex: none; }
.item .acts span { color: var(--blue); font-size: 12.5px; cursor: pointer; }
.item .acts span.del { color: var(--err); }
.item.locked { opacity: .55; }
.item.locked .acts { display: none; }
.item .lockmark { font-size: 12.5px; color: var(--ink4); flex: none; }

.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; margin-right: 6px; }
.tag.day { background: var(--blue-l); color: var(--blue); border: 1px solid var(--blue-b); }
.tag.night { background: var(--night-l); color: var(--night); border: 1px solid var(--night-b); }

.sum-row {
  display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600;
  background: var(--blue-l); color: var(--blue-d); border-radius: 8px; padding: 10px 12px;
}

/* ---------- 月份切换 ---------- */
.months {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border: 1px solid var(--line2); border-radius: 9px; padding: 9px 14px;
}
.months .a { color: var(--blue); font-size: 16px; font-weight: 600; cursor: pointer; padding: 0 6px; user-select: none; }
.months .a.off { color: var(--ink4); cursor: not-allowed; }
.months .c { font-size: 14px; font-weight: 600; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  background: var(--blue-l); color: var(--blue-d); font-weight: 600;
  padding: 8px 5px; text-align: center; border-bottom: 1px solid var(--blue-b); white-space: nowrap;
}
td { padding: 8px 5px; border-bottom: 1px solid #EDEFF2; text-align: center; color: var(--ink); }
th:first-child, td:first-child { text-align: left; }
tr.total td { font-weight: 600; background: #FAFBFC; }

/* ---------- 底栏（仅手机） ---------- */
.tabbar { position: sticky; bottom: 0; display: flex; background: #fff; border-top: 1px solid var(--line); z-index: 20; }
.tabbar a {
  flex: 1; text-align: center; padding: 9px 0 11px; font-size: 11.5px;
  color: var(--ink3); text-decoration: none; cursor: pointer;
}
.tabbar a.on { color: var(--blue); font-weight: 600; }
.tabbar a .dot { display: block; width: 5px; height: 5px; border-radius: 50%; margin: 0 auto 3px; background: transparent; }
.tabbar a.on .dot { background: var(--blue); }

/* ---------- 登录页 ---------- */
.login-wrap {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  width: 100%; max-width: 480px; margin: 0 auto; background: #fff;
  box-shadow: 0 0 0 1px var(--line);
}
.login-brand {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 0 24px 30px;
}
.login-brand .lg-logo { height: 34px; display: block; }
.login-brand h2 { font-size: 17px; font-weight: 600; color: var(--blue-d); letter-spacing: 1px; }
.login-brand p { color: var(--ink3); font-size: 12.5px; text-align: center; line-height: 1.8; }
.login-form { display: flex; flex-direction: column; gap: 12px; padding: 0 24px; }

/* ---------- 提示 / 弹窗 ---------- */
.toast {
  position: fixed; left: 50%; top: 22%; transform: translateX(-50%);
  background: rgba(28, 32, 36, .9); color: #fff; padding: 12px 20px; border-radius: 8px;
  font-size: 13.5px; max-width: 320px; text-align: center; line-height: 1.6;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 100;
}
.toast.show { opacity: 1; }

.mask {
  position: fixed; inset: 0; background: rgba(20, 24, 28, .45);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 60;
}
.dialog { background: #fff; border-radius: 12px; padding: 18px; width: 100%; max-width: 340px; }
.dialog h3 { font-size: 14.5px; font-weight: 600; margin-bottom: 12px; }
.dialog .btn-row { margin-top: 16px; }

.empty { text-align: center; color: var(--ink4); font-size: 12.5px; padding: 30px 0; }
.loading { text-align: center; color: var(--ink3); padding: 40px 0; font-size: 13px; }

/* ---------- 上线清空 ---------- */
.wipe-list {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0;
}
.wipe-list span {
  font-size: 12px; color: var(--err); background: var(--err-l);
  border: 1px solid var(--err-b); border-radius: 6px; padding: 4px 9px;
}
.wipe-list b { font-weight: 600; }
.chk {
  display: flex; align-items: center; gap: 8px; margin-top: 12px;
  font-size: 12.5px; color: var(--ink2); cursor: pointer;
}
.chk input { width: 15px; height: 15px; accent-color: var(--blue); flex: none; }
.danger-link { color: var(--err); cursor: pointer; border-bottom: 1px dashed var(--err-b); }

/* ================= 桌面 ================= */
@media (min-width: 900px) {
  body { background: #EDF1F5; }
  #app { padding: 22px; }

  .shell {
    flex-direction: row; max-width: 1180px; margin: 0 auto;
    min-height: calc(100vh - 44px);
    border-radius: 14px; overflow: hidden;
    box-shadow: 0 6px 30px rgba(4, 44, 83, .10); border: 1px solid #E1E7ED;
  }

  .sidebar {
    display: flex; flex-direction: column; width: 208px; flex: none;
    background: var(--blue-d); color: #fff; padding: 22px 0 18px;
  }
  .sb-brand { padding: 0 20px 22px; }
  .sb-brand img { height: 22px; display: block; background: #fff; border-radius: 5px; padding: 3px 5px; }
  .sidebar nav { display: flex; flex-direction: column; gap: 3px; padding: 0 12px; }
  .sidebar nav a {
    color: rgba(255, 255, 255, .76); text-decoration: none; padding: 10px 14px;
    border-radius: 8px; font-size: 13.5px; cursor: pointer;
  }
  .sidebar nav a.on { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 600; }
  .sidebar nav a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
  .sb-foot {
    margin-top: auto; padding: 16px 20px 0; display: flex; flex-direction: column; gap: 9px;
    font-size: 12.5px; border-top: 1px solid rgba(255, 255, 255, .14);
  }
  .sb-foot .sb-name { color: #fff; font-weight: 600; font-size: 13.5px; margin-bottom: 2px; }
  .sb-foot a { color: rgba(255, 255, 255, .70); cursor: pointer; }
  .sb-foot a:hover { color: #fff; }

  .topbar { position: static; padding: 16px 28px; background: #fff; color: var(--ink); border-bottom: 1px solid var(--line); }
  .topbar.night { background: #fff; }
  .topbar h1 { text-align: left; font-size: 16px; color: var(--blue-d); flex: 0 1 auto; }
  .topbar .tb-left { flex: none; }
  .topbar .tb-right { flex: 1; }
  .topbar .brand { display: none; }
  .topbar .back { margin-left: -8px; margin-right: 4px; border-radius: 8px; }
  .topbar .back:hover { background: rgba(24, 95, 165, .10); }
  .topbar .back:active { background: rgba(24, 95, 165, .18); }

  .page { max-width: 860px; width: 100%; margin: 0 auto; padding: 20px 28px 44px; gap: 14px; }
  .tabbar { display: none; }

  .stat-box .nb { font-size: 21px; }
  table { font-size: 13px; }
  th, td { padding: 10px 8px; }

  .login-wrap {
    flex-direction: row; max-width: 880px; margin: 6vh auto 0;
    min-height: 540px; border-radius: 16px; overflow: hidden;
    box-shadow: 0 12px 44px rgba(4, 44, 83, .16); border: 1px solid #E1E7ED;
  }
  .login-brand {
    flex: 1; background: var(--blue-d); justify-content: center; padding: 40px 30px; gap: 18px;
  }
  .login-brand img { background: #fff; border-radius: 8px; padding: 8px 12px; height: 40px; }
  .login-brand h2 { color: #fff; font-size: 19px; }
  .login-brand p { color: rgba(255, 255, 255, .68); font-size: 13px; text-align: center; line-height: 1.8; }
  .login-form { flex: 1; padding: 40px 44px; justify-content: center; }
}
