:root {
  --primary: #185FA5;
  --primary-light: #E6F1FB;
  --danger: #A32D2D;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2937;
  --text2: #6b7280;
  --text3: #9ca3af;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 15px; color: var(--text); }
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; position: relative; }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 16px; padding: 36px 28px; box-shadow: var(--shadow); text-align: center; }
.login-logo { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 12px; }
.login-card h1 { font-size: 22px; font-weight: 500; }
.login-sub { color: var(--text2); font-size: 13px; margin: 6px 0 24px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; outline: none; background: var(--bg); }
.login-card input:focus { border-color: var(--primary); background: #fff; }
.login-card button { padding: 12px; border-radius: 10px; background: var(--primary); color: #fff; font-size: 16px; }
.login-err { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- 主壳 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
}
.topbar-title { font-size: 17px; font-weight: 500; }
.icon-btn { color: #fff; font-size: 14px; padding: 6px 10px; border: 1px solid rgba(255,255,255,.5); border-radius: 8px; }
.main { padding: 14px 14px 90px; }
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 720px; background: #fff; border-top: 1px solid var(--border);
  display: flex; padding-bottom: env(safe-area-inset-bottom); z-index: 20;
}
.tab-btn { flex: 1; padding: 12px 0 10px; font-size: 14px; color: var(--text2); }
.tab-btn.active { color: var(--primary); font-weight: 500; }

/* ---------- 通用组件 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.btn { display: inline-block; padding: 9px 16px; border-radius: 9px; background: var(--primary); color: #fff; font-size: 14px; }
.btn.secondary { background: var(--border); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--primary-light); color: var(--primary); font-size: 12px; margin-right: 4px; }
.tag.gray { background: #f3f4f6; color: var(--text2); }
.muted { color: var(--text3); font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row .grow { flex: 1; }
input[type="text"], input[type="password"], input[type="date"], input[type="url"], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; outline: none; background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 160px; line-height: 1.7; }
label { font-size: 13px; color: var(--text2); display: block; margin: 10px 0 4px; }

/* ---------- 日志 ---------- */
.search-bar { display: flex; gap: 8px; margin-bottom: 10px; }
.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; font-size: 13px; color: var(--text2); }
.filter-bar input[type="date"] { flex: 1; min-width: 110px; padding: 7px 8px; }
.filter-bar select { flex: 1; min-width: 90px; padding: 7px 8px; }
.filter-bar input[type="text"] { flex: 1; min-width: 100px; padding: 7px 8px; }
.log-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 10px; }
.log-card .log-date { font-size: 12px; color: var(--text3); }
.log-card .log-title { font-size: 16px; font-weight: 500; margin: 2px 0 4px; }
.log-card .log-summary { color: var(--text2); font-size: 13px; margin: 6px 0 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.log-card .log-actions { display: flex; gap: 8px; justify-content: flex-end; }
.pager { display: flex; justify-content: center; gap: 16px; padding: 8px 0; }
.pager button { color: var(--primary); font-size: 14px; padding: 6px 12px; }

/* ---------- 浮动按钮 ---------- */
.fab {
  position: fixed; right: calc(50% - 360px + 20px); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 15;
  width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 26px;
  box-shadow: 0 4px 12px rgba(24,95,165,.35); line-height: 1;
}
@media (max-width: 760px) { .fab { right: 20px; } }

/* ---------- 日历 ---------- */
.cal-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.cal-nav button { color: var(--primary); font-size: 15px; padding: 6px 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-grid .weekhead { color: var(--text3); font-size: 12px; padding: 4px 0; }
.cal-day { height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 9px; font-size: 13px; cursor: pointer; }
.cal-day.has { background: var(--primary-light); color: var(--primary); font-weight: 500; }
.cal-day .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--primary); margin-top: 2px; }
.cal-day.empty { cursor: default; }

/* ---------- 统计 ---------- */
.stat-grid { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding: 0 4px; }
.stat-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; }
.stat-bar { width: 100%; max-width: 30px; background: var(--primary); border-radius: 5px 5px 0 0; min-height: 2px; }
.stat-num { font-size: 11px; color: var(--text2); }
.stat-month { font-size: 11px; color: var(--text3); }

/* ---------- 待办 ---------- */
.todo-item { display: flex; align-items: center; gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--border); }
.todo-item:last-child { border-bottom: none; }
.todo-item.done .todo-text { text-decoration: line-through; color: var(--text3); }
.todo-item input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); }
.todo-item .todo-text { flex: 1; }
.todo-del { color: var(--danger); font-size: 13px; padding: 4px 6px; }

/* ---------- 密码库 ---------- */
.pwd-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 10px; }
.pwd-name { font-size: 16px; font-weight: 500; }
.pwd-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text2); margin-top: 6px; }
.pwd-row .val { flex: 1; word-break: break-all; }
.pwd-row button { color: var(--primary); font-size: 12px; padding: 3px 6px; border: 1px solid var(--primary-light); border-radius: 6px; }
.pwd-url a { font-size: 13px; color: var(--primary); text-decoration: none; }
.pwd-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* ---------- 我的 ---------- */
.me-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.me-row:last-child { border-bottom: none; }
.log-item { font-size: 12px; color: var(--text2); padding: 5px 0; }
.log-item .ok { color: #0F6E56; }
.log-item .fail { color: var(--danger); }

/* ---------- 表单页 ---------- */
.form-page { padding: 4px 0; }
.form-btns { display: flex; gap: 10px; margin-top: 18px; }
.form-btns button { flex: 1; padding: 11px; border-radius: 10px; font-size: 15px; }
.sub-page-title { font-size: 16px; font-weight: 500; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.back-btn { color: var(--primary); font-size: 15px; padding: 4px 8px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%) translateY(20px);
  background: rgba(31,41,55,.92); color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: 14px; opacity: 0; transition: all .25s; pointer-events: none; z-index: 99; max-width: 80vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 加载态 ---------- */
.loading { text-align: center; color: var(--text3); padding: 40px 0; font-size: 14px; }
.empty { text-align: center; color: var(--text3); padding: 40px 0; font-size: 14px; }
