/* ============================================================
   小账本
   ============================================================ */

/* ---------------- 悬浮按钮（最上） ---------------- */
#ledger-fab {
  position: fixed;
  right: 16px;
  bottom: 292px;
  z-index: 9998;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: #2a9d8f;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(42, 157, 143, .42);
  transition: transform .18s, filter .18s;
}

#ledger-fab:hover {
  transform: translateY(-2px) scale(1.04);
  filter: brightness(1.06);
}

#ledger-fab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 悬停文字标签（与番茄钟按钮一致） */
#ledger-fab::after {
  content: attr(data-label);
  position: absolute;
  right: 58px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(20, 26, 38, .86);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 7px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-weight: 400;
  letter-spacing: 0;
}

#ledger-fab:hover::after {
  opacity: 1;
}

/* ---------------- 账本面板 ---------------- */
#ledger-panel {
  position: fixed;
  right: 16px;
  bottom: 354px;
  z-index: 9999;
  width: 300px;
  max-height: calc(100vh - 380px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e8ebf0;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 16px 44px rgba(20, 26, 38, .22);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: #2b3440;
  font-size: 14px;
}

#ledger-panel[hidden] {
  display: none;
}

/* 当月汇总 */
.ledger-summary {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: #8a94a6;
  margin-bottom: 10px;
}

.ledger-summary b {
  color: #2b3440;
  font-variant-numeric: tabular-nums;
}

.ledger-summary .in  b { color: #2a9d8f; }
.ledger-summary .out b { color: #e5534b; }

/* 记一笔表单 */
.ledger-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.ledger-row {
  display: flex;
  gap: 6px;
}

.ledger-row > * {
  flex: 1;
  min-width: 0;
}

.ledger-row select {
  flex: 0 0 64px;
}

.ledger-input {
  border: 1px solid #e8ebf0;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: #fff;
  color: #2b3440;
  width: 100%;
  box-sizing: border-box;
}

.ledger-input:focus {
  border-color: #2a9d8f;
}

.ledger-input::placeholder {
  color: #c3cad6;
}

.ledger-input-money {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600;
}

.ledger-input-money-prefix {
  font-size: 13px;
  color: #8a94a6;
  align-self: center;
  flex: 0 0 auto;
}

.ledger-add {
  border: 1px solid #2a9d8f;
  background: #2a9d8f;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  padding: 8px 0;
  border-radius: 8px;
  cursor: pointer;
  transition: filter .16s;
}

.ledger-add:hover {
  filter: brightness(1.08);
}

/* 流水列表 */
.ledger-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 240px;
  overflow-y: auto;
  border-top: 1px dashed #e8ebf0;
  padding-top: 8px;
}

.ledger-empty {
  text-align: center;
  color: #c3cad6;
  font-size: 12.5px;
  padding: 18px 0;
}

.ledger-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  border-radius: 8px;
}

.ledger-item:hover {
  background: #f6f8fb;
}

.ledger-amt {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  min-width: 68px;
  font-variant-numeric: tabular-nums;
}

.ledger-amt.in { color: #2a9d8f; }
.ledger-amt.exp { color: #e5534b; }

.ledger-desc {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
}

.ledger-desc .l-note {
  color: #2b3440;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ledger-desc .l-meta {
  color: #b6bfcc;
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ledger-del {
  border: 0;
  background: transparent;
  color: #c3cad6;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 6px;
  visibility: hidden;
  flex-shrink: 0;
}

.ledger-item:hover .ledger-del {
  visibility: visible;
}

.ledger-del:hover {
  background: #fdecec;
  color: #e5534b;
}

.ledger-edit {
  border: 1px solid #e8ebf0;
  background: #fff;
  color: #8a94a6;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  visibility: hidden;
  flex-shrink: 0;
  transition: all .16s;
}

.ledger-item:hover .ledger-edit {
  visibility: visible;
}

.ledger-edit:hover {
  border-color: #2a9d8f;
  color: #2a9d8f;
}

/* 列表滚动条（细一些） */
.ledger-list {
  scrollbar-width: thin;
  scrollbar-color: #d5dbe6 transparent;
}

.ledger-list::-webkit-scrollbar {
  width: 6px;
}

.ledger-list::-webkit-scrollbar-thumb {
  background: #d5dbe6;
  border-radius: 3px;
}

/* 项目筛选 */
.ledger-filter {
  margin-bottom: 10px;
}

.ledger-filter select {
  width: 100%;
  border: 1px solid #e8ebf0;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  background: #f6f8fb;
  color: #5a6474;
  cursor: pointer;
}


/* 面板底部操作行：记一笔 + 统计页跳转 */
.ledger-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ledger-actions .ledger-add {
  flex: 1;
}

.ledger-goto {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  color: #2a9d8f;
  text-decoration: none;
  padding: 8px 4px;
  white-space: nowrap;
}

.ledger-goto:hover {
  text-decoration: underline;
}

/* 统计页期间行的「导出」按钮 */
.ledger-export {
  flex: 0 0 56px;
  border: 1px solid #e8ebf0;
  background: #fff;
  color: #5a6474;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 8px;
  cursor: pointer;
  transition: all .16s;
}

.ledger-export:hover {
  border-color: #2a9d8f;
  color: #2a9d8f;
}

.pocket-page-card > [data-pocket-mount] {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.ledger-page {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px;
}

/* 期间切换 */
.ledger-period {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: #f6f8fb;
}

.ledger-period button {
  flex: 1;
  border: 0;
  background: transparent;
  color: #8a94a6;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  padding: 8px 0;
  border-radius: 8px;
  cursor: pointer;
  transition: all .16s;
}

.ledger-period button:hover {
  color: #2b3440;
}

.ledger-period button.active {
  background: #fff;
  color: #2a9d8f;
  box-shadow: 0 1px 3px rgba(20, 26, 38, .12);
}

/* 汇总卡片 */
.ledger-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.lcard {
  background: #f6f8fb;
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
}

.lcard .lcard-v {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 19px;
  font-weight: 700;
  color: #2b3440;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lcard.in  .lcard-v { color: #2a9d8f; }
.lcard.out .lcard-v { color: #e5534b; }

.lcard .lcard-k {
  margin-top: 4px;
  font-size: 11.5px;
  color: #8a94a6;
}

/* 分组标签页 */
.ledger-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: #f6f8fb;
}

.ledger-tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  color: #8a94a6;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  padding: 6px 0;
  border-radius: 8px;
  cursor: pointer;
  transition: all .16s;
}

.ledger-tabs button.active {
  background: #fff;
  color: #2a9d8f;
  box-shadow: 0 1px 3px rgba(20, 26, 38, .12);
}

/* 分组统计 */
.ledger-agg {
  background: #fbfcfe;
  border: 1px solid #eef2f7;
  border-radius: 12px;
  padding: 8px 12px;
  flex-shrink: 0;
}

.lgroup-head,
.lgroup-row {
  display: grid;
  grid-template-columns: minmax(64px, 1.1fr) minmax(48px, 2fr) minmax(56px, .8fr) minmax(56px, .8fr) minmax(56px, .8fr) minmax(28px, .5fr);
  align-items: center;
  gap: 6px;
}

.lgroup-head {
  padding: 6px 0;
  border-bottom: 1px solid #eef2f7;
  font-size: 11px;
  color: #b6bfcc;
}

.lgroup-head span:not(:first-child):not(:nth-child(2)) {
  text-align: right;
}

.lgroup-row {
  padding: 7px 0;
  font-size: 12.5px;
}

.lgroup-row + .lgroup-row {
  border-top: 1px dashed #f0f3f8;
}

.lg-name {
  color: #2b3440;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lg-bar {
  height: 6px;
  border-radius: 3px;
  background: #eef2f7;
  overflow: hidden;
}

.lg-bar i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #2a9d8f, #4e6ef2);
}

.lgroup-row span:nth-child(n+3) {
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.lg-in  { color: #2a9d8f; }
.lg-exp { color: #e5534b; }
.lg-net { color: #2b3440; font-weight: 700; }
.lg-cnt { color: #b6bfcc; font-size: 11px; }

/* 流水筛选条 */
.ledger-pfilters {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.ledger-pfilters select {
  flex: 1;
  min-width: 0;
  border: 1px solid #e8ebf0;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  background: #f6f8fb;
  color: #5a6474;
  cursor: pointer;
}

/* 统计页里的流水列表：弹性伸缩 */
.ledger-plist {
  flex: 1 1 auto;
  min-height: 80px;
  max-height: none;
  border-top: 1px dashed #e8ebf0;
  padding-top: 8px;
}

.ledger-sampled {
  font-size: 11.5px;
  color: #b6bfcc;
  text-align: center;
  flex-shrink: 0;
}

/* 统计页嵌在 pocket-page-card 里时的高度适配 */
.pocket-page-card .ledger-page {
  min-height: 460px;
}

/* ---------------- 编辑弹层 ---------------- */
#ledger-editor {
  position: fixed;
  inset: 0;
  z-index: 100001;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 22, 34, .32);
}

#ledger-editor[hidden] {
  display: none;
}

.ledger-editor-box {
  width: 340px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 16px 44px rgba(20, 26, 38, .22);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: #2b3440;
  font-size: 14px;
}

.le-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
}

.le-x {
  border: 0;
  background: transparent;
  color: #b6bfcc;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.le-x:hover {
  color: #2b3440;
}

.le-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.le-row select {
  flex: 0 0 64px;
}

.le-prefix {
  font-size: 13px;
  color: #8a94a6;
  align-self: center;
  flex: 0 0 auto;
}

.le-input {
  width: 100%;
  min-width: 0;
  border: 1px solid #e8ebf0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: #fff;
  color: #2b3440;
  box-sizing: border-box;
  margin-bottom: 8px;
}

.le-input:focus {
  border-color: #2a9d8f;
}

.le-row .le-input {
  margin-bottom: 0;
}

.le-input[type="number"] {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600;
}

.le-err {
  color: #e5534b;
  font-size: 12px;
  margin-bottom: 8px;
}

.le-btns {
  display: flex;
  gap: 6px;
}

.le-btn {
  flex: 1;
  border: 1px solid #e8ebf0;
  background: #fff;
  color: #5a6474;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  padding: 9px 0;
  border-radius: 9px;
  cursor: pointer;
  transition: all .16s;
}

.le-btn:hover {
  border-color: #cfd8e6;
  color: #2b3440;
}

.le-btn.primary {
  border-color: #2a9d8f;
  background: #2a9d8f;
  color: #fff;
}

.le-btn.primary:hover {
  filter: brightness(1.08);
  color: #fff;
}

.le-btn.danger {
  flex: 0 0 56px;
  border-color: #f5d5d2;
  color: #e5534b;
}

.le-btn.danger:hover {
  background: #fdecec;
  border-color: #e5534b;
}

/* 移动端 ---------------- */

@media screen and (max-width: 640px) {
  #ledger-fab {
    right: 12px;
    bottom: 262px;
    width: 44px;
    height: 44px;
  }

  #ledger-fab::after {
    display: none;
  }

  #ledger-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 318px;
  }

  .ledger-list {
    max-height: 200px;
  }
}
