/* ============================================================
 * 大明小账本 · 网页版 样式
 * 配色对齐安卓 Ui.java：
 *   BLUE #1E6FFF  BLUE_DARK #1456D6  TEXT #1A1A1A
 *   GRAY #888888  BG #F4F6FA  GREEN #0F9D58  RED #D93025
 * ============================================================ */

:root {
  --blue: #1E6FFF;
  --blue-dark: #1456D6;
  --ink: #1A1A1A;
  --gray: #888888;
  --bg: #F4F6FA;
  --green: #0F9D58;
  --red: #D93025;
  --line: #ECEEF3;
  --card: #FFFFFF;
  --radius: 16px;
  --tab-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body { padding-bottom: calc(var(--tab-h) + var(--safe-b)); }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--card);
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; flex: 1; letter-spacing: .3px; }
.topbar .ver-chip {
  background: #EAF1FF; color: var(--blue-dark);
  font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
}
.icon-btn {
  border: 0; background: transparent; color: var(--blue);
  font-size: 20px; padding: 4px 8px; cursor: pointer; line-height: 1;
}

/* ---------- 主内容 ---------- */
.screen { padding: 0 0 20px; }
.ledger-row {
  display: flex; align-items: center;
  padding: 10px 16px 4px; font-weight: 700; font-size: 15px;
}
.ledger-row .sp { flex: 1; }
.ledger-row .chev { color: var(--gray); font-weight: 400; }

.search-wrap { padding: 0 12px 6px; }
.search-wrap input {
  width: 100%; border: 0; border-radius: 10px; background: var(--card);
  padding: 11px 14px; font-size: 15px; color: var(--ink);
  font-family: inherit; outline: none;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}

.month-nav {
  display: flex; align-items: center; justify-content: center; gap: 20px;
  padding: 6px 16px 10px;
}
.month-nav .label { font-size: 18px; font-weight: 700; min-width: 130px; text-align: center; }
.arrow-btn {
  border: 1px solid var(--blue); background: var(--card); color: var(--blue);
  border-radius: 10px; font-size: 19px; line-height: 1; padding: 5px 15px; cursor: pointer;
  font-family: inherit;
}
.arrow-btn:active { background: #EAF1FF; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin: 6px 12px;
  box-shadow: 0 1px 3px rgba(16,24,40,.05);
}
.card.warn { background: #FDECEA; }
.card.center { text-align: center; }

.stat-cols { display: flex; }
.stat-col { flex: 1; text-align: center; }
.stat-col .k { font-size: 12px; color: var(--gray); }
.stat-col .v { font-size: 17px; font-weight: 700; margin-top: 2px; }

.money-in { color: var(--green); }
.money-out { color: var(--red); }

/* ---------- 明细行 ---------- */
.day-head {
  display: flex; align-items: center;
  font-weight: 700; font-size: 14px; padding-bottom: 6px;
}
.day-head .sum { flex: 1; text-align: right; font-size: 12px; color: var(--gray); font-weight: 400; }

.entry {
  display: flex; align-items: center; padding: 8px 0;
  border-top: 1px solid var(--line);
}
.entry:first-of-type { border-top: 0; }
.entry .dot {
  width: 32px; height: 32px; border-radius: 8px; flex: 0 0 32px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; margin-right: 10px;
}
.entry .mid { flex: 1; min-width: 0; }
.entry .mid .c { font-size: 15px; }
.entry .mid .s { font-size: 12px; color: var(--gray); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .amt { font-size: 16px; font-weight: 700; white-space: nowrap; }

.empty { text-align: center; color: var(--gray); padding: 44px 16px; font-size: 14px; white-space: pre-line; }

/* ---------- 按钮 ---------- */
.btn {
  display: block; width: 100%; border: 0; cursor: pointer;
  background: var(--blue); color: #fff; font-size: 16px; font-weight: 700;
  padding: 13px 18px; border-radius: 12px; font-family: inherit;
  margin-top: 8px;
}
.btn:active { background: var(--blue-dark); }
.btn.ghost { background: var(--card); color: var(--blue); border: 1px solid var(--blue); }
.btn.danger { background: var(--card); color: var(--red); border: 1px solid var(--red); }
.btn.sm { display: inline-block; width: auto; font-size: 13px; padding: 8px 16px; font-weight: 600; }

.seg { display: flex; gap: 8px; justify-content: center; padding: 6px 0; }
.seg button {
  border: 1px solid var(--blue); background: var(--card); color: var(--blue);
  border-radius: 20px; font-size: 14px; font-weight: 600; padding: 7px 18px;
  cursor: pointer; font-family: inherit;
}
.seg button.on { background: var(--blue); color: #fff; }

/* ---------- 我的列表 ---------- */
.me-row {
  display: flex; align-items: center; background: var(--card);
  border-radius: 12px; padding: 15px 16px; margin: 6px 12px;
  font-size: 15px; cursor: pointer;
  box-shadow: 0 1px 3px rgba(16,24,40,.05);
}
.me-row .sp { flex: 1; }
.me-row .chev { color: var(--gray); font-size: 18px; }

/* ---------- 底部页签 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; align-items: center;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
}
.tabbar .tab {
  flex: 1; text-align: center; font-size: 12px; color: var(--gray);
  padding: 8px 0; cursor: pointer; border: 0; background: transparent; font-family: inherit;
}
.tabbar .tab.on { color: var(--blue); font-weight: 700; }
.tabbar .plus-wrap { flex: 0 0 74px; display: flex; justify-content: center; }
.plus-btn {
  width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: var(--blue); color: #fff; font-size: 28px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  margin-top: -14px; cursor: pointer;
  box-shadow: 0 4px 12px rgba(30,111,255,.35);
  padding-bottom: 4px;
}

/* ---------- 弹层 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
}
.mask.center { align-items: center; }
.sheet {
  background: var(--card); width: 100%; max-width: 620px;
  border-radius: 18px 18px 0 0; max-height: 92vh; overflow-y: auto;
  padding: 18px 16px calc(18px + var(--safe-b));
  -webkit-overflow-scrolling: touch;
}
.mask.center .sheet { border-radius: 18px; margin: 0 16px; width: calc(100% - 32px); }
.sheet h2 { font-size: 17px; margin: 0 0 12px; }
.sheet .field { margin-bottom: 12px; }
.sheet .field label { display: block; font-size: 13px; color: var(--gray); margin-bottom: 5px; }
.sheet .row2 { display: flex; gap: 10px; }
.sheet .row2 > * { flex: 1; }

input[type="text"], input[type="number"], input[type="date"], input[type="time"], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; font-size: 16px; color: var(--ink); background: var(--card);
  font-family: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
textarea { resize: vertical; min-height: 60px; }

/* ---------- 分类宫格 ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
.cat-cell {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  padding: 12px 4px; text-align: center; cursor: pointer; font-family: inherit;
}
.cat-cell .ico {
  width: 34px; height: 34px; border-radius: 9px; margin: 0 auto 6px;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px;
}
.cat-cell .nm { font-size: 12px; color: var(--ink); }
.cat-cell.on { border-color: var(--blue); background: #EAF1FF; }
.cat-cell.on .nm { color: var(--blue-dark); font-weight: 700; }

/* ---------- 计算器 ---------- */
.calc-display {
  background: #F7F8FB; border-radius: 12px; padding: 14px; text-align: right;
  font-size: 24px; font-weight: 700; min-height: 56px; word-break: break-all;
}
.calc-display .expr { font-size: 13px; color: var(--gray); font-weight: 400; min-height: 18px; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.calc-keys button {
  border: 0; border-radius: 12px; background: #F1F3F8; color: var(--ink);
  font-size: 20px; padding: 15px 0; cursor: pointer; font-family: inherit;
}
.calc-keys button.op { background: #E3ECFF; color: var(--blue-dark); font-weight: 700; }
.calc-keys button.eq { background: var(--blue); color: #fff; font-weight: 700; }

/* ---------- 图表 ---------- */
.chart-box { padding: 6px 0; }
.chart-box svg { display: block; width: 100%; height: auto; }
.rank-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.rank-row .nm { width: 68px; font-size: 13px; flex: 0 0 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .track { flex: 1; height: 16px; background: #EFF1F5; border-radius: 6px; overflow: hidden; }
.rank-row .fill { height: 100%; border-radius: 6px; }
.rank-row .val { width: 86px; text-align: right; font-size: 13px; font-weight: 700; flex: 0 0 86px; }

/* ---------- 债务 ---------- */
.debt-card { cursor: pointer; }
.debt-head { display: flex; align-items: center; gap: 10px; }
.debt-head .ico {
  width: 38px; height: 38px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; font-size: 17px; color: #fff; flex: 0 0 38px;
}
.debt-head .t { flex: 1; min-width: 0; }
.debt-head .t .n { font-size: 15px; font-weight: 700; }
.debt-head .t .s { font-size: 12px; color: var(--gray); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 700; white-space: nowrap;
}
.badge.open { background: #EAF1FF; color: var(--blue-dark); }
.badge.closed { background: #E8F5EE; color: var(--green); }
.debt-nums { display: flex; margin-top: 10px; }
.debt-nums > div { flex: 1; }
.debt-nums .k { font-size: 11px; color: var(--gray); }
.debt-nums .v { font-size: 14px; font-weight: 700; }
.photo-chip {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--blue-dark); background: #EAF1FF;
  padding: 5px 10px; border-radius: 999px;
}

/* ---------- 照片网格 ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.photo-cell { position: relative; padding-top: 100%; border-radius: 10px; overflow: hidden; background: #EFF1F5; }
.photo-cell img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.photo-cell .x {
  position: absolute; top: 4px; right: 4px; z-index: 2;
  width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.55); color: #fff; font-size: 13px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.photo-add {
  border: 1px dashed var(--blue); background: #F7FAFF; color: var(--blue);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 22px; cursor: pointer; padding-top: 0; aspect-ratio: 1/1;
}
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- 列表条目（管理类） ---------- */
.list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px; border-bottom: 1px solid var(--line); font-size: 15px;
}
.list-item:last-child { border-bottom: 0; }
.list-item .sp { flex: 1; min-width: 0; }
.list-item .sub { font-size: 12px; color: var(--gray); }
.tag { font-size: 11px; padding: 3px 9px; border-radius: 999px; }
.tag.on { background: #EAF1FF; color: var(--blue-dark); font-weight: 700; }
.tag.off { background: #F1F3F8; color: var(--gray); }
.mini { border: 0; background: transparent; color: var(--blue); font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 6px; font-family: inherit; }
.mini.red { color: var(--red); }
.mini.gray { color: var(--gray); }

/* ---------- 日历 ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-head {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
  font-size: 12px; color: var(--gray); text-align: center; padding: 6px 0;
}
.cal-cell {
  aspect-ratio: 1 / 1.06; border-radius: 8px; background: var(--card);
  padding: 5px 3px; font-size: 12px; cursor: pointer; overflow: hidden;
  display: flex; flex-direction: column; gap: 1px;
}
.cal-cell.blank { background: transparent; cursor: default; }
.cal-cell.today { background: #EAF1FF; }
.cal-cell .d { font-weight: 600; font-size: 12px; }
.cal-cell .i { color: var(--green); font-size: 10px; }
.cal-cell .o { color: var(--red); font-size: 10px; }
.cal-cell .dot { color: #C4C9D4; text-align: center; }

/* ---------- 提示条 / 底部浮动提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 18px);
  transform: translateX(-50%);
  background: rgba(17,24,39,.92); color: #fff; font-size: 14px;
  padding: 10px 18px; border-radius: 999px; z-index: 100;
  max-width: 84vw; text-align: center; pointer-events: none;
}
.tip { font-size: 13px; color: var(--gray); line-height: 1.6; }
.hint { font-size: 12px; color: var(--gray); margin-top: 6px; }
.section-title { font-size: 14px; font-weight: 700; color: var(--gray); padding: 14px 16px 6px; }
a.link { color: var(--blue); text-decoration: none; }
