:root {
  --bg: #f2f4f8; --card: #ffffff; --border: #e3e7ef; --text: #1c2333;
  --muted: #6b7488; --accent: #4f7cf7; --accent-soft: rgba(79,124,247,.12);
  --green: #22b573; --red: #e5484d; --yellow: #d9a406; --shadow: 0 2px 10px rgba(20,30,60,.06);
  --radius: 12px; --topbar-h: 58px; --tabbar-h: 58px;
}
[data-theme="dark"] {
  --bg: #0e1117; --card: #171b26; --border: #262c3a; --text: #e7eaf2;
  --muted: #8a93a8; --accent: #5b8cff; --accent-soft: rgba(91,140,255,.15);
  --green: #35d07f; --red: #ff6262; --yellow: #f5b942; --shadow: 0 2px 12px rgba(0,0,0,.4);
}
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] { --bg:#0e1117; --card:#171b26; --border:#262c3a; --text:#e7eaf2; --muted:#8a93a8; --accent:#5b8cff; --accent-soft:rgba(91,140,255,.15); --green:#35d07f; --red:#ff6262; --yellow:#f5b942; --shadow:0 2px 12px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { font-family: "PingFang SC","Microsoft YaHei",system-ui,sans-serif; background: var(--bg); color: var(--text); padding-bottom: calc(var(--tabbar-h) + 12px); }

/* 顶部状态栏 */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 14px; height: var(--topbar-h); background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { font-size: 26px; line-height: 1; }
.logo img { height: 30px; width: auto; }
.brand-txt { min-width: 0; }
.brand-txt h1 { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subline { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-mid { display: flex; gap: 10px; font-size: 12px; color: var(--muted); align-items: center; white-space: nowrap; }
.top-mid .clock { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.top-right { display: flex; align-items: center; gap: 8px; }
.badge { font-size: 11px; padding: 3px 9px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.badge-on { background: rgba(34,181,115,.15); color: var(--green); }
.badge-off { background: rgba(107,116,136,.15); color: var(--muted); }
.bal-warn { background: rgba(229,72,77,.12); color: var(--red); border-bottom: 1px solid rgba(229,72,77,.3); padding: 8px 16px; font-size: 13px; font-weight: 600; text-align: center; }

/* 页面 / 标签 */
.page { padding: 12px; max-width: 1080px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: .3; transform: translateY(4px);} to { opacity: 1; transform: none;} }

/* 底部导航 */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--border); z-index: 40; height: var(--tabbar-h); }
.tab-btn { flex: 1; background: transparent; border: none; color: var(--muted); padding: 6px 0; font-size: 19px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.tab-btn span { font-size: 9.5px; }
.tab-btn.active { color: var(--accent); }
.tab-btn .ndot { position: relative; }
.tab-btn .ndot::after { content: attr(data-n); position: absolute; top: -2px; right: -10px; background: var(--red); color: #fff; font-size: 9px; border-radius: 9px; padding: 0 4px; font-weight: 700; }

/* 通用组件 */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card-wide { grid-column: 1 / -1; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-title { font-size: 13px; font-weight: 700; color: var(--text); }
.card-list { display: flex; flex-direction: column; gap: 8px; }
.dash-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.metric-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 12px; }
.metric { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 10px; text-align: center; }
.metric .num { font-size: 24px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.metric .lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }
.minilist { display: flex; flex-direction: column; gap: 6px; }
.mitem { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bg); border-radius: 9px; font-size: 12.5px; cursor: pointer; }
.mitem .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mitem .s { color: var(--muted); font-size: 11px; white-space: nowrap; }
.empty { color: var(--muted); text-align: center; padding: 22px 0; font-size: 12.5px; }

/* 按钮 / 表单 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 9px; padding: 8px 13px; font-size: 13px; cursor: pointer; text-decoration: none; font-family: inherit; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-small { padding: 5px 10px; font-size: 12px; }
.btn-ghost { background: transparent; }
.btn.full { width: 100%; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
input, select, textarea { width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 13.5px; font-family: inherit; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
.mb8 { margin-bottom: 8px; }
.row2 { display: flex; gap: 8px; align-items: center; }
.row2 > * { flex: 1; }
.row2 .btn { flex: 0 0 auto; }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.chk input { width: auto; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px; margin-bottom: 12px; box-shadow: var(--shadow); }

/* 状态标签 */
.tag { font-size: 11px; padding: 2px 8px; border-radius: 12px; white-space: nowrap; }
.tag-pending { background: rgba(217,164,6,.15); color: var(--yellow); }
.tag-running { background: var(--accent-soft); color: var(--accent); }
.tag-success { background: rgba(34,181,115,.15); color: var(--green); }
.tag-failed { background: rgba(229,72,77,.15); color: var(--red); }
.tag-stopped { background: rgba(107,116,136,.18); color: var(--muted); }
.tag-info { background: var(--accent-soft); color: var(--accent); }

/* 列表项 */
.item { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; box-shadow: var(--shadow); }
.item-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; align-items: flex-start; }
.item-title { font-weight: 600; word-break: break-all; flex: 1; }
.item-meta { color: var(--muted); font-size: 11px; margin-top: 4px; }
.item-result { margin-top: 8px; background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; white-space: pre-wrap; word-break: break-all; }
.unread { border-left: 3px solid var(--accent); }

/* 图表（纯 CSS 柱状） */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding-top: 8px; }
.chart .bar { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-width: 3px; position: relative; opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chart .bar .tip { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--card); border: 1px solid var(--border); padding: 3px 6px; border-radius: 6px; font-size: 10px; white-space: nowrap; z-index: 5; }
.chart .bar:hover .tip { display: block; }
.chart-x { display: flex; gap: 3px; margin-top: 4px; }
.chart-x span { flex: 1; font-size: 8.5px; color: var(--muted); text-align: center; overflow: hidden; }
.dist { display: flex; flex-direction: column; gap: 6px; }
.dist .row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.dist .track { flex: 1; height: 8px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.dist .fill { height: 100%; border-radius: 5px; }

/* 余额 */
.balance-hero { text-align: center; }
.bal-big { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin: 6px 0; }
#bal-total { font-size: 44px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.bal-cur { color: var(--muted); font-size: 15px; }
.bal-avail { font-size: 13px; margin-bottom: 8px; }
.bal-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); padding: 4px 0; }
.bal-row span:last-child { color: var(--text); font-variant-numeric: tabular-nums; }

/* 记录 */
.rec { margin-top: 8px; background: var(--red); color: #fff; border-radius: 9px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.insp-media img { max-width: 100%; border-radius: 9px; margin-top: 6px; }
.insp-media audio { width: 100%; margin-top: 6px; }

/* 设置 */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.set-row:last-child { border-bottom: none; }
.set-row span { color: var(--muted); flex: 0 0 auto; }
.set-row input, .set-row select { flex: 1; max-width: 240px; }

/* 登录 */
.login-overlay { position: fixed; inset: 0; background: rgba(10,14,22,.92); z-index: 100; display: flex; align-items: center; justify-content: center; }
.login-box { width: 88%; max-width: 320px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 26px 24px; text-align: center; }
.login-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-logo { margin-right: 6px; }
.login-sub { font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.login-box input { margin-bottom: 12px; }
.login-box button { width: 100%; padding: 11px; background: var(--accent); color: #fff; border: none; border-radius: 9px; font-size: 15px; cursor: pointer; }
.login-err { color: var(--red); font-size: 12px; margin-top: 8px; min-height: 16px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(10,14,22,.6); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 14px; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 18px; max-width: 560px; width: 100%; max-height: 86vh; overflow: auto; }
.modal h3 { font-size: 15px; margin-bottom: 10px; }
.modal .m-body { font-size: 13px; line-height: 1.6; word-break: break-all; white-space: pre-wrap; }
.modal .m-row { margin-bottom: 8px; }
.modal .m-actions { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; flex-wrap: wrap; }

/* toast */
.toast { position: fixed; bottom: calc(var(--tabbar-h) + 14px); left: 50%; transform: translateX(-50%) translateY(20px); background: var(--card); color: var(--text); border: 1px solid var(--border); padding: 9px 16px; border-radius: 10px; font-size: 13px; opacity: 0; transition: all .25s ease; z-index: 99; pointer-events: none; max-width: 88vw; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--red); color: var(--red); }

/* 桌面端调整 */
@media (min-width: 900px) {
  .tabbar { left: 0; right: auto; width: 78px; flex-direction: column; height: 100vh; top: var(--topbar-h); border-top: none; border-right: 1px solid var(--border); background: var(--card); padding-top: 8px; }
  .tab-btn { padding: 12px 0; font-size: 21px; }
  .tab-btn span { font-size: 10px; }
  body { padding-bottom: 0; }
  .page { max-width: 1080px; margin-left: 110px; }
  .top-mid { display: flex; }
  .metric-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 899px) {
  .topbar { flex-wrap: wrap; gap: 2px 8px; height: auto; padding: 8px 12px; }
  .top-mid { display: flex; order: 10; width: 100%; justify-content: space-between; font-size: 11px; gap: 4px; margin-top: 2px; padding-top: 6px; border-top: 1px solid var(--border); }
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}
/* 更多页 */
.more-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.more-item { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 12px; font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; box-shadow: var(--shadow); text-align: center; }
.more-item:active { border-color: var(--accent); transform: scale(.97); }
/* 主题切换按钮 */
.theme-btns { display: flex; gap: 6px; }
.theme-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
/* ===== 当月日历 ===== */
.cal-nav { display: flex; align-items: center; gap: 6px; margin: 0 6px; }
.cal-title { font-size: 13px; font-weight: 700; min-width: 78px; text-align: center; }
.quick-add { display: flex; gap: 6px; margin: 8px 0; }
.quick-add input { flex: 1; }
.quick-add .btn { flex: 0 0 auto; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; border-bottom: 1px solid var(--border); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-top: 6px; }
.cal-day { min-height: 52px; background: var(--bg); border-radius: 8px; padding: 4px 3px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 1px solid transparent; }
.cal-day:hover { border-color: var(--accent); }
.cal-day.other { opacity: .35; }
.cal-day.today { border-color: var(--accent); }
.cal-num { font-size: 12.5px; font-weight: 700; }
.cal-weekday { font-size: 9.5px; color: var(--muted); }
.cal-badge { min-width: 20px; height: 18px; border-radius: 9px; font-size: 10.5px; font-weight: 700; color: #fff; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.cal-badge.done { background: #8a93a8; }        /* 全部完成：灰底白字 */
.cal-badge.todo { background: var(--green); }   /* 有未完成：绿底白字 */

/* ===== 日详情弹窗 ===== */
.dd-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.dd-date { font-size: 17px; font-weight: 800; }
.dd-week { font-size: 12px; color: var(--muted); }
.dd-lunar { text-align: right; font-size: 12px; color: var(--muted); line-height: 1.5; }
.dd-lunar .ganzhi { color: var(--accent); font-weight: 600; }
.dd-yi { color: var(--green); }
.dd-ji { color: var(--red); }
.dd-tasks { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow: auto; }
.dd-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; padding: 34px 0; min-height: 160px; }
.dd-empty-icon { font-size: 42px; line-height: 1; }
.dd-empty-title { font-size: 26px; font-weight: 800; color: var(--text); }
.dd-empty-sub { font-size: 12.5px; color: var(--muted); }
.task-row { display: flex; align-items: center; gap: 9px; padding: 9px 10px; background: var(--bg); border-radius: 9px; font-size: 13.5px; cursor: pointer; }
.task-row .cb { width: 19px; height: 19px; border-radius: 5px; border: 2px solid var(--muted); flex: 0 0 auto; display: flex; align-items: center; justify-content: center; color: transparent; font-size: 13px; background: var(--card); }
.task-row .cb.on { background: var(--green); border-color: var(--green); color: #fff; }
.task-row .tt { flex: 1; word-break: break-all; }
.task-row.done .tt { color: var(--muted); text-decoration: line-through; }
.task-row .tm { color: var(--muted); font-size: 11px; flex: 0 0 auto; }
.task-row .dd-del { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 5px; display: flex; align-items: center; justify-content: center; color: var(--muted); background: var(--card); border: 1px solid var(--border); font-size: 15px; line-height: 1; cursor: pointer; user-select: none; }
.task-row .dd-del:hover { color: var(--red); border-color: var(--red); }

.dd-add { display: flex; justify-content: flex-end; margin-top: 10px; }

/* ---------- 碎碎念会员管理 ---------- */
.admin-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 4px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; box-shadow: var(--shadow); }
.stat-value { font-size: 24px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 6px; }
.sec-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.member-list { display: flex; flex-direction: column; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.member-row:last-child { border-bottom: none; }
.m-ava { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--green)); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.m-info { flex: 1; min-width: 0; }
.m-name { font-size: 14px; font-weight: 700; color: var(--text); }
.m-sub { font-size: 11px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-ops { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.m-select { border-radius: 8px; font-size: 12px; height: 32px; padding: 0 6px; background: var(--card); border: 1px solid var(--border); color: var(--text); }
.m-save { height: 30px; font-size: 12px; padding: 0 10px; }
.badge-free { background: rgba(107,116,136,.14); color: var(--muted); }
.badge-normal { background: var(--accent-soft); color: var(--accent); }
.badge-premium { background: rgba(217,164,6,.16); color: var(--yellow); }
.badge-admin { background: rgba(229,72,77,.14); color: var(--red); }
