/* 로또 가계부 · V6.10.9e276 · 다크 살짝 밝게 + 라이트 모드 · 폰 프레임 통합 */

/* ─────────────────────────────────────────────
 *  scr-ledger (앱 화면) · 다크 (기본) 살짝 밝게 (총지휘관 승인 e276)
 *   · #0a0a12 (거의 검정) → #12142a (미드나잇 네이비) — 눈 피로 감소
 *   · 스코프: #scr-ledger 안에서만 · 홈 12구/은하/마이페이지 무영향 (법률 준수)
 * ────────────────────────────────────────────*/
#scr-ledger {
  background: #12142a;
  color: #e6e6f0;
  padding: 0 !important;
  overflow: hidden !important;
}
#scr-ledger.active {
  display: flex !important;
  flex-direction: column;
}

.ledger-topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px 8px;
  background: linear-gradient(180deg, #1c1c38 0%, #16162c 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.ledger-title {
  flex: 1;
  font-size: 16px;
  font-weight: 800;
  color: #f5f5ff;
  letter-spacing: -0.2px;
  text-align: center;
}
.ledger-topbtn {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #f0f0ff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, background 0.12s ease;
  padding: 0;
  flex-shrink: 0;
}
.ledger-topbtn:active { transform: scale(0.92); background: rgba(255, 255, 255, 0.15); }
/* e276 · 달·계산기 SVG 심볼도 다크에서 밝은 회색 · currentColor 상속 */
.ledger-topbtn-theme .ledger-theme-icon { font-size: 15px; line-height: 1; }
.ledger-topbtn-calc svg { display: block; }

/* ─────────────────────────────────────────────
 *  e276 · 라이트 모드 (달 탭 → theme-bright-ui) · 가계부 스코프
 *   · 스코프를 #scr-ledger 로 한정 → 홈/마이페이지/QR 무영향
 *   · 부드러운 미드-라이트 (완전 흰색 아님) · 눈 편안
 * ────────────────────────────────────────────*/
/* e322 · 라이트 모드 본문 = 100% #000 + weight 상향 (보라빛 검정 제거 · 폰 선명도) */
#phone-app.theme-bright-ui #scr-ledger {
  background: #f4f5f8;
  color: #000000;
  font-weight: 700;
}
#phone-app.theme-bright-ui .ledger-topbar {
  background: linear-gradient(180deg, #ffffff 0%, #ecedf1 100%);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}
#phone-app.theme-bright-ui .ledger-title { color: #000000; font-weight: 900; }
#phone-app.theme-bright-ui .ledger-topbtn {
  background: rgba(0, 0, 0, 0.06);
  color: #000000;
}
#phone-app.theme-bright-ui .ledger-topbtn:active { background: rgba(0, 0, 0, 0.12); }

/* e322 · 라이트 모드 · 본문 요소 — 순정 검정 + 굵기 (시크릿 퍼플·강조색 유지) */
#phone-app.theme-bright-ui .ledger-tab {
  background: rgba(0, 0, 0, 0.05);
  color: #000000;
  font-weight: 800;
}
#phone-app.theme-bright-ui .ledger-tab.active {
  /* 골드 활성탭은 다크·라이트 공통 유지 (테마 브랜드 컬러) */
  background: linear-gradient(135deg, #ffe075 0%, #e8c84a 100%);
  color: #000000;
  font-weight: 900;
}
#phone-app.theme-bright-ui .ledger-tab-secret { color: #7a4bc9; }
#phone-app.theme-bright-ui .ledger-tab-secret.active {
  background: linear-gradient(135deg, #a37bf0 0%, #6d3fc9 100%);
  color: #fff;
}
#phone-app.theme-bright-ui .ledger-card {
  background: linear-gradient(160deg, #ffffff 0%, #f0f1f5 100%);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  color: #000000;
}
#phone-app.theme-bright-ui .ledger-sum-label { color: #000000; font-weight: 800; }
#phone-app.theme-bright-ui .ledger-sum-val { color: #000000; font-weight: 900; }
#phone-app.theme-bright-ui .ledger-sum-val.pos { color: #059669; }
#phone-app.theme-bright-ui .ledger-sum-val.neg { color: #dc2626; }
#phone-app.theme-bright-ui .ledger-sum-val.warn { color: #d97706; }
#phone-app.theme-bright-ui .ledger-sum-row.ledger-net { border-top-color: rgba(0, 0, 0, 0.12); }
#phone-app.theme-bright-ui .ledger-sum-row.ledger-mini {
  border-top-color: rgba(0, 0, 0, 0.06);
  color: #000000;
  font-weight: 700;
}
#phone-app.theme-bright-ui .ledger-witty { color: #b8850a; font-weight: 800; }
#phone-app.theme-bright-ui .ledger-ranks .ledger-rank-title { color: #000000; font-weight: 900; }
#phone-app.theme-bright-ui .ledger-rank-cell {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.06);
}
#phone-app.theme-bright-ui .ledger-rank-cell .rn { color: #000000; font-weight: 800; }
#phone-app.theme-bright-ui .ledger-rank-cell .rc { color: #000000; font-weight: 900; }
#phone-app.theme-bright-ui .ledger-list-head { color: #000000; font-weight: 900; }
#phone-app.theme-bright-ui .ledger-item {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  color: #000000;
  font-weight: 700;
}
#phone-app.theme-bright-ui .ledger-item .ledger-item-meta,
#phone-app.theme-bright-ui .ledger-item .ledger-item-sub { color: #000000; font-weight: 700; }
#phone-app.theme-bright-ui .ledger-mini-btn {
  background: rgba(0, 0, 0, 0.06);
  color: #000000;
  border-color: rgba(0, 0, 0, 0.08);
  font-weight: 800;
}
#phone-app.theme-bright-ui .ledger-mini-btn.is-secret {
  background: rgba(163, 123, 240, 0.15);
  color: #6d3fc9;
}

.ledger-tabbar {
  display: flex;
  gap: 4px;
  padding: 6px 10px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.ledger-tabbar::-webkit-scrollbar { display: none; }
.ledger-tabbar-filter { padding-top: 0; padding-bottom: 6px; }
/* e321 · 분류줄「🗑️ 전체」삭제 · 시크릿과 同크기 · 퍼플 */
.ledger-tab-wipe {
  color: #b892e8;
  background: rgba(184, 146, 232, 0.14);
}
.ledger-tab-wipe:active { transform: scale(0.96); }
#phone-app.theme-bright-ui .ledger-tab-wipe {
  color: #7a4bc9;
  background: rgba(237, 233, 254, 0.95);
}
.ledger-tab {
  flex: 1;
  min-width: 54px;
  /* e291 · UX-128 · 총지휘관 승인 · 폰 가독성 대공사:
   *   clamp(min, vw, max) — 폰(360px)에서는 상한(14px)에 근접, PC 프리뷰(569px)에서 유지. */
  padding: 9px 6px;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  color: #b8b8cc;
  font-size: clamp(12.5px, 3.5vw, 14px);
  font-weight: 800;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
  white-space: nowrap;
  letter-spacing: -0.2px;
}
.ledger-tab:active { transform: scale(0.96); }
.ledger-tab.active {
  background: linear-gradient(135deg, #ffe075 0%, #e8c84a 100%);
  color: #1a1400;
}
.ledger-tab-secret { color: #b892e8; }
.ledger-tab-secret.active {
  background: linear-gradient(135deg, #a37bf0 0%, #6d3fc9 100%);
  color: #fff;
}

.ledger-body {
  flex: 1;
  overflow-y: auto;
  /* e290 · UX-127 · 총지휘관 승인 · 하단 광고 라인(#sticky-ad 56px + safe-area) 겹침 방지
   *   기존 14px → 스크롤 콘텐츠가 광고 뒤로 잘리던 문제 봉합. 대장님 지적 「밑에 광고 라인 반드시」 병행. */
  padding: 0 10px calc(var(--chrome-ad-h, 56px) + env(safe-area-inset-bottom, 0px) + 14px);
  -webkit-overflow-scrolling: touch;
}

.ledger-card {
  background: linear-gradient(160deg, #16162a 0%, #0e0e1c 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 8px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.ledger-summary { padding-top: 10px; padding-bottom: 10px; }
.ledger-sum-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 4px 0;
}
.ledger-sum-row.ledger-sub { padding-left: 12px; font-size: 11.5px; opacity: 0.85; }
.ledger-sum-row.ledger-net {
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  margin-top: 6px;
  padding-top: 8px;
}
.ledger-sum-row.ledger-mini {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: 6px;
  padding-top: 6px;
  font-size: 11px;
  color: #9a9aae;
  gap: 12px;
  justify-content: flex-start;
}
.ledger-sum-label { color: #c8c8dc; font-size: 12.5px; font-weight: 600; }
.ledger-sum-val { font-size: 15px; font-weight: 800; letter-spacing: -0.2px; font-variant-numeric: tabular-nums; }
.ledger-sum-val.pos { color: #3adfa0; }
.ledger-sum-val.neg { color: #ff6b6b; }
.ledger-sum-val.warn { color: #ffb74d; }
.ledger-witty {
  /* e291 · 폰 가독성 · 11→13 clamp 800 · 약간 위로 붙임 */
  font-size: clamp(12px, 3.3vw, 13.5px);
  color: #ffe075;
  padding: 6px 0 4px;
  font-weight: 800;
  letter-spacing: -0.1px;
  opacity: 0.95;
  text-align: center;
}

.ledger-ranks .ledger-rank-title {
  /* e291 · 카드 헤더도 폰 가독성 확대 · clamp 13.5 800 */
  font-size: clamp(13px, 3.6vw, 14.5px);
  color: #c8c8dc;
  font-weight: 800;
  margin-bottom: 10px;
  letter-spacing: -0.2px;
}
.ledger-rank-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.ledger-rank-cell {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 8px 4px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.04);
}
.ledger-rank-cell .rn { font-size: 10px; color: #9a9aae; font-weight: 700; }
.ledger-rank-cell .rc { font-size: 16px; color: #fff; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.ledger-rank-cell.rank-1 { background: linear-gradient(135deg, rgba(232, 200, 74, 0.28), rgba(232, 200, 74, 0.08)); border-color: rgba(232, 200, 74, 0.5); }
.ledger-rank-cell.rank-2 { background: linear-gradient(135deg, rgba(59, 130, 246, 0.28), rgba(59, 130, 246, 0.08)); border-color: rgba(59, 130, 246, 0.5); }
.ledger-rank-cell.rank-3 { background: linear-gradient(135deg, rgba(239, 68, 68, 0.28), rgba(239, 68, 68, 0.08)); border-color: rgba(239, 68, 68, 0.5); }
.ledger-rank-cell.rank-4 { background: linear-gradient(135deg, rgba(136, 136, 136, 0.28), rgba(136, 136, 136, 0.08)); border-color: rgba(136, 136, 136, 0.5); }
.ledger-rank-cell.rank-5 { background: linear-gradient(135deg, rgba(16, 185, 129, 0.28), rgba(16, 185, 129, 0.08)); border-color: rgba(16, 185, 129, 0.5); }

.ledger-list-head {
  /* e291 · 「최근 티켓」 헤더 폰 확대 */
  font-size: clamp(13px, 3.6vw, 14.5px);
  color: #b8b8cc;
  font-weight: 800;
  padding: 10px 4px 6px;
  letter-spacing: -0.2px;
}
.ledger-list { display: flex; flex-direction: column; gap: 6px; }
.ledger-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 8px 10px;
}
.ledger-item.secret {
  background: linear-gradient(135deg, rgba(163, 123, 240, 0.18), rgba(109, 63, 201, 0.06));
  border-color: rgba(163, 123, 240, 0.35);
}
.ledger-item-head {
  display: flex;
  gap: 8px;
  /* e291 · 리스트 아이템 헤더도 폰 가독성 확대 */
  font-size: clamp(12px, 3.3vw, 13.5px);
  color: #9a9aae;
  align-items: baseline;
}
.ledger-item-round { color: #fff; font-weight: 800; }
.ledger-item-date { color: #7a7a8e; }
.ledger-item-lines { margin-left: auto; color: #b8b8cc; font-weight: 700; }
.ledger-item-money {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 0 3px;
  /* e291 · 금액 라인 확대 · 13→15 clamp */
  font-size: clamp(13.5px, 3.8vw, 15.5px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.ledger-item-money .arrow { color: #6a6a7e; }
.ledger-item-money .pos { color: #3adfa0; font-weight: 800; }
.ledger-item-money .neg { color: #ff9a9a; font-weight: 700; }
/* e322 · 라이트 리스트 텍스트 순정 검정 (다크 전용 #fff/#7a7a8e 덮어쓰기) */
#phone-app.theme-bright-ui .ledger-item-head,
#phone-app.theme-bright-ui .ledger-item-round,
#phone-app.theme-bright-ui .ledger-item-date,
#phone-app.theme-bright-ui .ledger-item-lines,
#phone-app.theme-bright-ui .ledger-item-money,
#phone-app.theme-bright-ui .ledger-item-money .arrow {
  color: #000000;
  font-weight: 800;
}
#phone-app.theme-bright-ui .ledger-item-money .pos { color: #059669; font-weight: 900; }
#phone-app.theme-bright-ui .ledger-item-money .neg { color: #dc2626; font-weight: 800; }
.ledger-manual-badge {
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 224, 117, 0.18);
  color: #ffe075;
  font-weight: 700;
  margin-left: 4px;
}
.ledger-item-actions { display: flex; gap: 4px; padding-top: 4px; }
.ledger-mini-btn {
  flex: 1;
  padding: 5px 6px;
  border: 0;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  color: #d8d8ec;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
}
.ledger-mini-btn.is-secret {
  background: linear-gradient(135deg, #a37bf0, #6d3fc9);
  color: #fff;
}
.ledger-mini-btn:active { transform: scale(0.96); }
.ledger-empty {
  text-align: center;
  padding: 40px 16px;
  color: #7a7a8e;
  font-size: clamp(13px, 3.6vw, 14.5px);
  line-height: 1.6;
}
/* e291 · 빈 상태 타이틀/힌트/버튼도 폰 가독성 확대 */
.ledger-empty-title { color: #cfcfd8; font-size: clamp(14.5px, 4vw, 16.5px); font-weight: 800; margin-bottom: 6px; letter-spacing: -0.2px; }
.ledger-empty-hint { color: #9a9aae; font-size: clamp(12px, 3.3vw, 13.5px); margin-bottom: 18px; }
/* e289 · UX-126 · 빈 상태 「QR 스캔하러 가기」 CTA · 마이페이지·가계부에서만 사용
 * e291 · 폰트 확대 · 터치 타깃 확대 */
.ledger-empty-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 26px;
  background: linear-gradient(135deg, #6d5cff, #4a3ac7);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: clamp(14px, 3.9vw, 15.5px);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(74, 58, 199, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  letter-spacing: -0.2px;
}
.ledger-empty-cta:active {
  transform: scale(0.97);
  box-shadow: 0 2px 6px rgba(74, 58, 199, 0.4);
}

/* ─────────────────────────────────────────────
 *  e289 · UX-126 · QR 실시간 스캔 배지 (상단 슬라이드 인/아웃)
 *   가계부 열린 상태에서 QR 저장 성공 시 3초간 노출.
 * ────────────────────────────────────────────*/
.ledger-scan-badge {
  position: sticky;
  top: 4px;
  z-index: 10;
  margin: 0 8px 8px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #22c55e, #15803d);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(21, 128, 61, 0.45);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.28s ease, transform 0.28s ease;
  pointer-events: none;
}
.ledger-scan-badge.show {
  opacity: 1;
  transform: translateY(0);
}
.ledger-scan-badge b { font-weight: 800; }

/* ─────────────────────────────────────────────
 *  e289 · UX-125 · 복구 코드 발급 & 「PIN 잊었어요?」 시트
 *   PIN 모달(z-index 999999)보다 위(1000000)에 오버레이.
 * ────────────────────────────────────────────*/
.ledger-recovery-sheet {
  position: fixed;
  inset: 0;
  z-index: 1000001;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: ledgerRecoveryFadeIn 0.2s ease;
}
@keyframes ledgerRecoveryFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.ledger-recovery-card {
  background: #fff;
  border-radius: 20px;
  padding: 22px 22px 18px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.ledger-recovery-title {
  font-size: 18px;
  font-weight: 800;
  color: #1a1a2e;
  margin-bottom: 8px;
}
.ledger-recovery-sub {
  font-size: 12.5px;
  color: #4a4a5e;
  line-height: 1.55;
  margin-bottom: 16px;
}
.ledger-recovery-sub b { color: #dc2626; font-weight: 800; }
.ledger-recovery-code {
  font-family: 'Menlo', 'Consolas', 'Courier New', monospace;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #4c1d95;
  background: linear-gradient(135deg, #f5f3ff, #ede9fe);
  border: 2px dashed #8b5cf6;
  border-radius: 12px;
  padding: 18px 12px;
  margin-bottom: 12px;
  user-select: all;
  -webkit-user-select: all;
}
.ledger-recovery-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 14px;
}
.ledger-recovery-copy {
  padding: 8px 16px;
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.ledger-recovery-copy:active { transform: scale(0.96); }
.ledger-recovery-divider {
  font-size: 11.5px;
  color: #7a7a8e;
  margin: 10px 0 8px;
  position: relative;
}
.ledger-recovery-bio {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: linear-gradient(135deg, #6d5cff, #4a3ac7);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 10px;
}
.ledger-recovery-bio:active { transform: scale(0.98); }
.ledger-recovery-bio:disabled { opacity: 0.6; cursor: default; }
.ledger-recovery-bio-off {
  font-size: 11.5px;
  color: #7a7a8e;
  padding: 8px;
  margin-bottom: 10px;
}
.ledger-recovery-done {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
}
.ledger-recovery-done:active { transform: scale(0.98); }
.ledger-recovery-done.ledger-forgot-cancel {
  background: #e5e7eb;
  color: #4b5563;
}
.ledger-recovery-msg {
  margin-top: 10px;
  font-size: 12px;
  min-height: 16px;
  line-height: 1.4;
}
.ledger-recovery-msg.ok { color: #16a34a; }
.ledger-recovery-msg.err { color: #dc2626; }
.ledger-recovery-msg.info { color: #4a4a5e; }
.ledger-forgot-rec-input-wrap {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.ledger-forgot-rec-input {
  flex: 1;
  padding: 12px 14px;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  border: 2px solid #c4b5fd;
  border-radius: 12px;
  outline: none;
  color: #4c1d95;
  text-transform: uppercase;
}
.ledger-forgot-rec-input:focus {
  border-color: #6d5cff;
  box-shadow: 0 0 0 3px rgba(109, 92, 255, 0.2);
}
.ledger-forgot-rec-input-wrap .ledger-recovery-done {
  width: auto;
  margin-top: 0;
  padding: 12px 18px;
}
/* 다크 모드 색감 */
.theme-dark .ledger-recovery-card {
  background: #1a1a2e;
  color: #e8e8f0;
}
.theme-dark .ledger-recovery-title { color: #f5f5fa; }
.theme-dark .ledger-recovery-sub { color: #b0b0c8; }
.theme-dark .ledger-recovery-code {
  background: linear-gradient(135deg, #2a1a4e, #1e1240);
  border-color: #a78bfa;
  color: #ddd6fe;
}
.theme-dark .ledger-recovery-copy {
  background: #3b2a5e;
  color: #ddd6fe;
  border-color: #6d5cff;
}
.theme-dark .ledger-recovery-done { background: #6d5cff; }
.theme-dark .ledger-recovery-done.ledger-forgot-cancel {
  background: #3a3a4e;
  color: #b0b0c8;
}

/* ─────────────────────────────────────────────
 *  PIN Modal Overlay
 * ────────────────────────────────────────────*/
.ledger-pin-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.ledger-pin-overlay.show { opacity: 1; }
.ledger-pin-overlay[hidden] { display: none; }

.ledger-pin-card {
  width: min(320px, 90vw);
  background: linear-gradient(160deg, #1a1a30 0%, #0d0d1c 100%);
  border: 1px solid rgba(163, 123, 240, 0.28);
  border-radius: 18px;
  padding: 18px 18px 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  position: relative;
}
/* e315 · PIN 설정 카드 확대 + 유휴 TTL 선택 */
.ledger-pin-card.ledger-pin-card--roomy {
  width: min(360px, 94vw);
  padding: 22px 20px 16px;
  border-radius: 20px;
}
.ledger-pin-card.ledger-pin-card--roomy .ledger-pin-title {
  font-size: 18px;
  font-weight: 900;
}
.ledger-pin-card.ledger-pin-card--roomy .ledger-pin-sub {
  font-size: 12px;
  padding-bottom: 10px;
}
.ledger-pin-ttl {
  margin: 8px 0 10px;
  padding: 10px 8px;
  border-radius: 12px;
  background: rgba(90, 212, 255, 0.08);
  border: 1px solid rgba(90, 212, 255, 0.22);
}
.ledger-pin-ttl-label {
  font-size: 11px;
  font-weight: 800;
  color: #E8C84A;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.ledger-pin-ttl-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.ledger-pin-ttl-btn {
  flex: 1;
  min-height: 40px;
  border-radius: 10px;
  border: 1.5px solid rgba(90, 212, 255, 0.35);
  background: rgba(10, 20, 40, 0.65);
  color: #e8f4ff;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}
.ledger-pin-ttl-btn.is-on {
  border-color: rgba(232, 200, 74, 0.75);
  background: linear-gradient(180deg, rgba(232, 200, 74, 0.28), rgba(232, 200, 74, 0.12));
  color: #fff8d6;
  box-shadow: 0 0 10px rgba(232, 200, 74, 0.25);
}
.ledger-pin-card.shake { animation: ledger-shake 0.34s cubic-bezier(0.2, 0.9, 0.4, 1); }
@keyframes ledger-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(4px); }
}
.ledger-pin-close {
  position: absolute; top: 6px; right: 8px;
  width: 28px; height: 28px; border: 0;
  background: transparent; color: #b8b8cc;
  font-size: 20px; cursor: pointer;
}
.ledger-pin-title {
  font-size: 15px; font-weight: 800; color: #fff;
  text-align: center; padding-top: 6px;
}
.ledger-pin-sub {
  font-size: 11px; color: #b8b8cc; text-align: center;
  padding: 2px 4px 12px; line-height: 1.5;
}
.ledger-pin-dots {
  display: flex; gap: 8px; justify-content: center;
  padding: 6px 0 4px;
}
.ledger-pin-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.10);
  transition: background 0.14s ease, transform 0.14s ease;
}
.ledger-pin-dot.filled {
  background: linear-gradient(135deg, #a37bf0, #6d3fc9);
  transform: scale(1.15);
}
.ledger-pin-dot.active { box-shadow: 0 0 0 2px rgba(163, 123, 240, 0.35); }

.ledger-pin-msg {
  min-height: 16px;
  text-align: center;
  font-size: 10.5px;
  color: #9a9aae;
  padding: 6px 0 2px;
  font-weight: 700;
}
.ledger-pin-msg.err { color: #ff6b6b; }
.ledger-pin-msg.ok { color: #3adfa0; }
.ledger-pin-msg.info { color: #a37bf0; }

.ledger-pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px 0 4px;
}
.ledger-pin-key {
  height: 48px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #f0f0ff;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.1s ease, transform 0.08s ease;
}
.ledger-pin-key:active { background: rgba(163, 123, 240, 0.24); transform: scale(0.94); }
.ledger-pin-key-ok { background: linear-gradient(135deg, #3adfa0, #1e9a6a); color: #002d1d; }
.ledger-pin-key-del { background: rgba(255, 107, 107, 0.16); color: #ffb0b0; }
.ledger-pin-foot { text-align: center; padding-top: 4px; }
.ledger-pin-linkbtn {
  background: transparent; border: 0;
  color: #a37bf0; font-size: 11px; font-weight: 700;
  cursor: pointer; padding: 6px 10px;
}

/* ─────────────────────────────────────────────
 *  Stealth Calculator
 * ────────────────────────────────────────────*/
.ledger-stealth {
  position: fixed;
  inset: 0;
  z-index: 999998;
  background: #f4f4f6;
  color: #1a1a1a;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.ledger-stealth.show { opacity: 1; }
.ledger-stealth[hidden] { display: none; }

/* e284 · UX-119 · 스텔스 계산기 명시적 뒤로가기 버튼 ‹ (총지휘관 승인).
 *   좌상단 고정 · safe-area 대응 · 계산기 표시(display) 위에 겹쳐 배치.
 *   기존 C-홀드/=3연타 시크릿 탈출은 그대로 유지 (병존). */
.ledger-stealth-back {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.06);
  color: #1a1a1a;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 2px 0;
  z-index: 2;
  transition: transform 0.12s ease, background 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.ledger-stealth-back:active {
  transform: scale(0.92);
  background: rgba(0, 0, 0, 0.12);
}

/* e286 · UX-120 · 계산기 열림 중 UFO 안전지대 (총지휘관 승인).
 *   기본 자리(bottom-left) 는 키패드 「1 2 3」 열과 겹쳐 「숫자 침범」.
 *   → top-right (‹ 뒤로 버튼의 반대 코너) + scale(0.75) 축소로 히스토리·display 비침범.
 *   ufoFab 사용자 드래그 위치 (inline style left/top) 는 !important 로 덮어씀 (계산기 한정).
 *   .ledger-stealth 닫히면 ufo-in-stealth 클래스 제거 → 원위치 복귀. */
.global-ufo-fab-wrap.ufo-in-stealth {
  bottom: auto !important;
  top: calc(env(safe-area-inset-top, 0px) + 10px) !important;
  left: auto !important;
  right: 8px !important;
  transform: scale(0.75) !important;
  transform-origin: top right !important;
}

.ledger-stealth-history {
  /* e286 · 총지휘관 승인 (UX-120):
   *   기존 font-size 14px 은 「너무 작다」 → 3배(42px) 확대.
   *   min-height / padding 도 확대 비율 반영 · 우측 정렬 유지 (계산 히스토리 관례).
   *   line-height 1.1 로 세로 크기 절제. */
  padding: 24px 20px 8px;
  min-height: 50px;
  font-size: 42px;
  line-height: 1.1;
  color: #7a7a7a;
  text-align: right;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}
.ledger-stealth-display {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 8px 20px 24px;
  font-size: 56px;
  font-weight: 300;
  color: #1a1a1a;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1.5px;
  overflow-x: hidden;
  overflow-y: hidden;
  word-break: break-all;
}
.ledger-stealth-keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 10px 14px 18px;
  background: #f4f4f6;
}
.ledger-stealth-key {
  height: 62px;
  border: 0;
  border-radius: 999px;
  background: #d4d4d8;
  color: #1a1a1a;
  font-size: 24px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s ease, transform 0.08s ease;
  font-variant-numeric: tabular-nums;
}
.ledger-stealth-key:active { transform: scale(0.94); background: #b8b8be; }
.ledger-stealth-key.op { background: #ff9500; color: #fff; font-weight: 600; }
.ledger-stealth-key.op:active { background: #cc7600; }
.ledger-stealth-key.clr { background: #a5a5aa; color: #fff; }
.ledger-stealth-key.zero { grid-column: span 1; }
.ledger-stealth-key.eq { background: #ff9500; color: #fff; font-weight: 600; }
/* e287 · UX-121 · 한 자리 지우기 ⌫ 키 (총지휘관 승인).
 *   일반 회색 데이터키와 동일한 톤 · font-size 살짝 낮춰 ⌫ 유니코드 시각 균형. */
.ledger-stealth-key.back { font-size: 24px; color: #1a1a1a; }
.ledger-stealth-key.holding {
  animation: ledger-stealth-hold 3s linear forwards;
  background: linear-gradient(90deg, #a37bf0 0%, #6d3fc9 var(--hp, 0%), #a5a5aa var(--hp, 0%));
}
@keyframes ledger-stealth-hold {
  from { --hp: 0%; background: linear-gradient(90deg, #a37bf0, #a5a5aa 0%); }
  to   { --hp: 100%; background: linear-gradient(90deg, #6d3fc9 100%, #a5a5aa 100%); }
}

/* ─────────────────────────────────────────────
 *  가계부 진입 카드 (bottom-carousel 커스텀 색)
 * ────────────────────────────────────────────*/
.bottom-carousel-card[data-card-type="ledger"] .bottom-card-icon {
  filter: drop-shadow(0 0 3px rgba(163, 123, 240, 0.5));
}

/* ═════════════════════════════════════════════════════════
 *  e290 · UX-127 · 총지휘관 승인 2026-08-02 · 가계부 대시보드 폰-가독성 대공사
 *   1) 요약 카드 3열×2행 그리드 (값 20px 굵게 · 신호등 색상)
 *   2) 등수 카드 5칸 폰트 확대 (라벨 13px · 숫자 22px)
 *   3) 「빈 상태」 팁 카드로 여백 축소 + 하단 광고 라인까지 자연 안착
 *   4) 라이트 모드 미러
 *   5) 스코프 #scr-ledger 엄수 (홈/마이페이지/QR 무침해)
 * ═════════════════════════════════════════════════════════ */

/* (1) 상단 요약 3열×2행 그리드 --------------------------- */
.ledger-sum-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.ledger-sum-cell {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  /* e291 · UX-128 · 총지휘관 승인 · 폰 가독성 대공사:
   *   PC 프리뷰(569px)에선 잘 보이는데 실제 폰(360-390px)에선 텍스트가 「깨알」로 보이는 문제 봉합.
   *   clamp(min, vw, max) — 폰폭에 비례해 자동 확대 · PC는 상한에서 정지 (은행앱 자산 표시 기법).
   *   셀 내부 여백 축소 + 값 폰트 20→26px 900 + 라벨 11.5→14px 800 → 셀 채움도 90%+ */
  padding: 7px 6px 9px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 72px;
}
.ledger-sum-cell-head {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
}
.ledger-sum-icon {
  font-size: 18px;
  line-height: 1;
}
.ledger-sum-cell-label {
  font-size: clamp(12.5px, 3.5vw, 14px);
  color: #c8c8dc;
  font-weight: 800;
  letter-spacing: -0.2px;
  white-space: nowrap;
}
.ledger-sum-cell-val {
  font-size: clamp(22px, 5.8vw, 26px);
  font-weight: 900;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  color: #f5f5ff;
  align-self: flex-end;
  width: 100%;
  text-align: right;
  line-height: 1.1;
}
/* 신호등 색상 · 대장님 승인 traffic 팔레트 */
.ledger-sum-cell.v-spent .ledger-sum-cell-val { color: #d0d0da; }         /* 지출: 연그레이 (중립 톤) */
.ledger-sum-cell.v-won .ledger-sum-cell-val { color: #3adfa0; }           /* 당첨: 초록 */
.ledger-sum-cell.v-net.pos .ledger-sum-cell-val { color: #7fffbc; font-weight: 900; }  /* 순손익 이익: 밝은 초록 */
.ledger-sum-cell.v-net.neg .ledger-sum-cell-val { color: #ff8080; font-weight: 900; }  /* 순손익 손실: 진한 빨강 */
.ledger-sum-cell.v-count .ledger-sum-cell-val { color: #b8b8cc; font-size: clamp(20px, 5.4vw, 24px); }
.ledger-sum-cell.v-tax .ledger-sum-cell-val { color: #ffb74d; font-size: clamp(20px, 5.4vw, 24px); }  /* 세금: 주황 · 「-」 부호 여백 확보 위해 살짝 축소 */
.ledger-sum-cell.v-tax .ledger-sum-cell-label { font-size: clamp(10.5px, 3vw, 12px); }  /* 「세금(22/33%)」 길어서 라벨만 소폭 축소 */
.ledger-sum-cell.v-net-real .ledger-sum-cell-val { color: #3adfa0; }
/* 순손익 셀만 특별히 강조 (테두리 · 배경 미묘) */
.ledger-sum-cell.v-net {
  background: linear-gradient(135deg, rgba(58, 223, 160, 0.08), rgba(58, 223, 160, 0.02));
  border-color: rgba(58, 223, 160, 0.22);
}
.ledger-sum-cell.v-net.neg {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.08), rgba(255, 107, 107, 0.02));
  border-color: rgba(255, 107, 107, 0.22);
}

/* (2) 등수 카드 5칸 폰트 확대 (기존 rank-grid에 .ledger-rank-grid-big 오버라이드)
 *   e291 · 대장님 폰 캡처(등수 라벨만 보이고 숫자 짜부라져 안 보임 사고) 봉합:
 *   숫자 clamp 26 · 라벨 clamp 15 · padding 재조정으로 셀 안 밸런스 확보. */
.ledger-rank-grid-big .ledger-rank-cell {
  padding: 10px 3px 12px;
}
.ledger-rank-grid-big .ledger-rank-cell .rn {
  font-size: clamp(13px, 3.5vw, 15px);
  color: #cfcfd8;
  font-weight: 800;
  letter-spacing: -0.2px;
}
.ledger-rank-grid-big .ledger-rank-cell .rc {
  font-size: clamp(24px, 6.5vw, 28px);
  font-weight: 900;
  color: #ffffff;
  margin-top: 5px;
  letter-spacing: -0.6px;
  line-height: 1.05;
}

/* (3) 「빈 상태」 팁 카드 (여백 축소 · 밀도 향상)
 *   e291 · 팁도 폰에서 가독 확보 · clamp 13.5px 800 */
.ledger-empty-tip {
  margin-top: 18px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  text-align: left;
  color: #b8b8cc;
  font-size: clamp(13px, 3.6vw, 14.5px);
  font-weight: 500;
  line-height: 1.6;
}
.ledger-empty-tip-row {
  padding: 4px 0;
}
.ledger-empty-tip-row b {
  color: #f5f5ff;
  font-weight: 800;
}

/* (4) 라이트 모드 미러 ----------------------------------- */
#phone-app.theme-bright-ui .ledger-sum-cell {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}
#phone-app.theme-bright-ui .ledger-sum-cell-label { color: #4a4a6a; }
#phone-app.theme-bright-ui .ledger-sum-cell-val { color: #1a1a2e; }
#phone-app.theme-bright-ui .ledger-sum-cell.v-spent .ledger-sum-cell-val { color: #4a4a5e; }
#phone-app.theme-bright-ui .ledger-sum-cell.v-won .ledger-sum-cell-val { color: #16a34a; }
#phone-app.theme-bright-ui .ledger-sum-cell.v-net.pos .ledger-sum-cell-val { color: #059669; }
#phone-app.theme-bright-ui .ledger-sum-cell.v-net.neg .ledger-sum-cell-val { color: #dc2626; }
#phone-app.theme-bright-ui .ledger-sum-cell.v-count .ledger-sum-cell-val { color: #4a4a6a; }
#phone-app.theme-bright-ui .ledger-sum-cell.v-tax .ledger-sum-cell-val { color: #ea580c; }
#phone-app.theme-bright-ui .ledger-sum-cell.v-net-real .ledger-sum-cell-val { color: #16a34a; }
#phone-app.theme-bright-ui .ledger-sum-cell.v-net {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.08), rgba(5, 150, 105, 0.02));
  border-color: rgba(5, 150, 105, 0.28);
}
#phone-app.theme-bright-ui .ledger-sum-cell.v-net.neg {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.08), rgba(220, 38, 38, 0.02));
  border-color: rgba(220, 38, 38, 0.28);
}
#phone-app.theme-bright-ui .ledger-rank-grid-big .ledger-rank-cell .rn { color: #4a4a6a; }
#phone-app.theme-bright-ui .ledger-rank-grid-big .ledger-rank-cell .rc { color: #1a1a2e; }
#phone-app.theme-bright-ui .ledger-empty-tip {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
  color: #4a4a6a;
}
#phone-app.theme-bright-ui .ledger-empty-tip-row b { color: #1a1a2e; }
/* e291 · 라이트 모드 빈 상태 타이틀/힌트 (다크 기본 색이 흰 배경에서 안 보이는 문제 봉합) */
#phone-app.theme-bright-ui .ledger-empty-title { color: #1a1a2e; }
#phone-app.theme-bright-ui .ledger-empty-hint { color: #4a4a6a; }
#phone-app.theme-bright-ui .ledger-empty { color: #4a4a6a; }
/* e291 · 라이트 모드 · 순수 텍스트/헤더 색상 미러 */
#phone-app.theme-bright-ui .ledger-list-head { color: #4a4a6a; }
#phone-app.theme-bright-ui .ledger-witty { color: #b8850a; }


/* e327 · UX-159 · LEDGER_SCROLL_TOP — 가계부 전용 고정 ↑ (UFO 네비와 분리) */
/* e328 · UX-163 · LEDGER_SCROLL_TOP_DRAGGABLE_X
 *   기본 위치 하단 정중앙 (translate --st-tx · 0px 시작) · 롱프레스로 좌우 드래그 · Y축 고정
 *   상하 이동 금지 · touch-action: none 은 롱프레스 진입 후에만 JS 로 부여 */
.ledger-scroll-top {
  position: fixed;
  left: 50%;
  bottom: calc(var(--chrome-ad-h, 56px) + env(safe-area-inset-bottom, 0px) + 18px);
  z-index: 9995;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1.5px solid rgba(15, 23, 42, 0.18);
  border-radius: 50%;
  background: rgba(255, 251, 235, 0.94);
  color: #111111;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.22);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transform: translate(calc(-50% + var(--st-tx, 0px)), 0);
  transition: transform 160ms ease;
}
.ledger-scroll-top.is-dragging {
  transition: none;
  cursor: grabbing;
  touch-action: none;
  box-shadow: 0 6px 22px rgba(15, 23, 42, 0.30);
}
#scr-ledger.active .ledger-scroll-top.is-visible {
  display: inline-flex;
}
.ledger-scroll-top:active { transform: translate(calc(-50% + var(--st-tx, 0px)), 0) scale(0.92); }
.ledger-scroll-top.is-dragging:active { transform: translate(calc(-50% + var(--st-tx, 0px)), 0); }
.ledger-scroll-top svg {
  width: 22px;
  height: 22px;
  display: block;
  pointer-events: none;
}
#phone-app.theme-bright-ui .ledger-scroll-top {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(15, 23, 42, 0.22);
}
