/* ═══════════════════════════════════════════
   편한가계부 4.10.5 스타일 - 모바일 앱 UI
   ═══════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #2C7BE5;
    --primary-dark: #1a5bb5;
    --primary-light: #e8f0fe;
    --income: #2C7BE5;
    --income-bg: #e8f0fe;
    --expense: #E53E3E;
    --expense-bg: #fde8e8;
    --transfer: #FF9800;
    --transfer-bg: #fff3e0;
    --green: #38A169;
    --green-bg: #e6f7ed;
    --orange: #ED8936;
    --bg: #F7F8FA;
    --white: #FFFFFF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --tab-height: 56px;
    --header-height: 50px;
    --summary-height: 48px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
    background: var(--bg);
    color: var(--gray-800);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ═══ 앱 레이아웃 ═══ */
.app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
    background: var(--bg);
    position: relative;
}

/* ═══ 상단 헤더 ═══ */
.app-header {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--header-height);
    background: var(--primary);
    color: #fff;
    flex-shrink: 0;
    gap: 20px;
    position: relative;
    z-index: 10;
}
.hdr-title {
    font-size: 17px;
    font-weight: 600;
    min-width: 120px;
    text-align: center;
}
.hdr-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    padding: 4px 12px;
    line-height: 1;
    opacity: 0.85;
}
.hdr-btn:active { opacity: 1; }

/* ═══ 월 요약 바 ═══ */
.month-summary {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: var(--summary-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
    padding: 0 8px;
}
.ms-item { text-align: center; flex: 1; }
.ms-label { display: block; font-size: 10px; color: var(--gray-400); letter-spacing: 0.5px; }
.ms-value { font-size: 14px; font-weight: 700; color: var(--gray-700); }
.ms-value.income { color: var(--income); }
.ms-value.expense { color: var(--expense); }
.ms-divider { width: 1px; height: 24px; background: var(--gray-200); flex-shrink: 0; }

/* ═══ 페이지 컨테이너 ═══ */
.page-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}
.page { display: none; min-height: 100%; }
.page.active { display: block; }

/* ═══════════════════════════════════════════
   달력
   ═══════════════════════════════════════════ */

/* 월/주 뷰 토글 */
.cal-view-toggle {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-100);
}
.cal-toggle-btn {
    padding: 5px 16px;
    border: 1px solid var(--gray-200);
    background: var(--white);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.15s;
}
.cal-toggle-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.calendar {
    background: var(--white);
    user-select: none;
}

/* Week navigation */
.cal-week-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
}
.cal-week-prev, .cal-week-next {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--gray-500);
    padding: 4px 8px;
}

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--gray-100);
}
.cal-wd {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-400);
    padding: 8px 0;
}
.cal-wd:first-child { color: var(--expense); }
.cal-wd:last-child { color: var(--income); }

.cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}
.cal-days-week .cal-day {
    min-height: 70px;
}
.cal-day {
    min-height: 58px;
    padding: 2px;
    text-align: center;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-50);
    border-right: 1px solid var(--gray-50);
    transition: background 0.1s;
    position: relative;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day:hover { background: var(--gray-50); }
.cal-day.selected { background: #EBF4FF; }
.cal-day.today .cal-num {
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    line-height: 22px;
    display: inline-block;
}
.cal-day.other-month { opacity: 0.3; }
.cal-day:nth-child(7n+1) .cal-num { color: var(--expense); }
.cal-day:nth-child(7n) .cal-num { color: var(--income); }
.cal-day.today .cal-num { color: #fff; }

.cal-num {
    font-size: 12px;
    font-weight: 500;
    line-height: 20px;
}
.cal-amounts { margin-top: 1px; }
.cal-amt {
    font-size: 9px;
    font-weight: 600;
    line-height: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cal-amt.income { color: var(--income); }
.cal-amt.expense { color: var(--expense); }
.cal-amt.transfer { color: var(--transfer); }

/* 날짜별 거래 내역 */
.day-transactions {
    background: var(--bg);
    min-height: 200px;
    padding-bottom: 80px;
}
.day-header {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-600);
    background: var(--white);
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.day-header-totals { font-size: 12px; font-weight: 400; color: var(--gray-400); }
.day-header-totals .income { color: var(--income); }
.day-header-totals .expense { color: var(--expense); }
.day-header-totals .transfer { color: var(--transfer); }

.day-list { }
.dl-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-50);
    gap: 12px;
    cursor: pointer;
    transition: background 0.1s;
}
.dl-item:active { background: var(--gray-50); }
.dl-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    background: var(--gray-100);
}
.dl-icon.transfer-icon {
    background: var(--transfer-bg);
}
.dl-info { flex: 1; min-width: 0; }
.dl-cat { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.dl-desc { font-size: 12px; color: var(--gray-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-amount { font-size: 15px; font-weight: 700; text-align: right; flex-shrink: 0; }
.dl-amount.income { color: var(--income); }
.dl-amount.expense { color: var(--expense); }
.dl-amount.transfer { color: var(--transfer); }
.dl-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--gray-400);
    font-size: 13px;
}
.dl-asset-tag {
    display: inline-block;
    margin-top: 2px;
    padding: 1px 6px;
    background: var(--gray-100);
    border-radius: 4px;
    font-size: 10px;
    color: var(--gray-500);
    white-space: nowrap;
}
.transfer-tag {
    background: var(--transfer-bg);
    color: var(--transfer);
}

/* ═══════════════════════════════════════════
   내역 탭
   ═══════════════════════════════════════════ */
.list-filters {
    padding: 10px 12px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
}
.filter-select {
    padding: 6px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--white);
    color: var(--gray-700);
    outline: none;
}
.filter-search { flex: 1; min-width: 80px; }
.filter-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
}
.filter-input:focus, .filter-select:focus { border-color: var(--primary); }

.txn-group-list { padding-bottom: 80px; }
.txn-date-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--gray-50);
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
    border-bottom: 1px solid var(--gray-100);
}
.txn-date-header .totals span { margin-left: 12px; font-weight: 600; }
.txn-date-header .totals .income { color: var(--income); }
.txn-date-header .totals .expense { color: var(--expense); }
.txn-date-header .totals .transfer { color: var(--transfer); }

.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 16px;
}
.pg-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    background: var(--white);
    cursor: pointer;
    font-size: 13px;
    color: var(--gray-600);
}
.pg-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ═══════════════════════════════════════════
   통계 탭
   ═══════════════════════════════════════════ */
.stats-type-toggle {
    display: flex;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
}
.stats-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-400);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.stats-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.stats-tab[data-stype="expense"].active { color: var(--expense); border-bottom-color: var(--expense); }
.stats-tab[data-stype="income"].active { color: var(--income); border-bottom-color: var(--income); }

/* Stats sub-tabs */
.stats-sub-tabs {
    display: flex;
    background: var(--white);
    border-bottom: 1px solid var(--gray-100);
    gap: 0;
}
.stats-sub-tab {
    flex: 1;
    padding: 8px 4px;
    text-align: center;
    border: none;
    background: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-400);
    cursor: pointer;
    transition: all 0.15s;
    border-bottom: 2px solid transparent;
}
.stats-sub-tab.active {
    color: var(--gray-800);
    border-bottom-color: var(--gray-800);
}

.stats-sub-page { display: none; padding-bottom: 80px; }
.stats-sub-page.active { display: block; }

.stats-chart-wrap {
    background: var(--white);
    padding: 16px;
    margin: 8px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.stats-chart-wrap canvas { max-height: 260px; }
.stats-section-title { font-size: 14px; font-weight: 600; color: var(--gray-700); margin-bottom: 12px; }

.stats-detail-list { margin: 0 8px; padding-bottom: 16px; }
.sd-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--white);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    box-shadow: var(--shadow);
}
.sd-icon { font-size: 20px; width: 30px; text-align: center; }
.sd-info { flex: 1; }
.sd-name { font-size: 13px; font-weight: 600; }
.sd-bar { height: 4px; background: var(--gray-100); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.sd-bar-fill { height: 100%; border-radius: 2px; }
.sd-right { text-align: right; }
.sd-amount { font-size: 14px; font-weight: 700; }
.sd-pct { font-size: 11px; color: var(--gray-400); }

/* Avg cards */
.stats-avg-cards {
    display: flex;
    gap: 8px;
    margin: 8px;
}
.avg-card {
    flex: 1;
    background: var(--white);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
}
.avg-card-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    margin-bottom: 8px;
}
.avg-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 4px;
}
.avg-row .income { color: var(--income); font-weight: 600; }
.avg-row .expense { color: var(--expense); font-weight: 600; }

/* Stats budget list */
.stats-budget-list { margin: 8px; }

/* Stats asset select */
.stats-asset-select-wrap {
    padding: 12px;
    background: var(--white);
}
.stats-asset-select-wrap .filter-select { width: 100%; }

/* ═══════════════════════════════════════════
   더보기 탭
   ═══════════════════════════════════════════ */
.more-section {
    margin: 4px 0;
    background: var(--white);
}
.more-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-700);
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--gray-50);
}
.more-section-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.more-net-worth {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
}
.more-chevron {
    font-size: 10px;
    color: var(--gray-400);
    transition: transform 0.2s;
}
.more-section-body {
    display: none;
    padding: 0;
    animation: fadeSlideDown 0.2s ease;
}
.more-section-body.open {
    display: block;
}

/* Asset section in More */
.asset-group-section {
    border-bottom: 1px solid var(--gray-100);
}
.asset-group-header {
    display: flex;
    justify-content: space-between;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-50);
}
.asset-group-total {
    font-weight: 700;
    color: var(--gray-700);
}
.asset-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid var(--gray-50);
}
.asset-item:active { background: var(--gray-50); }
.asset-item-icon { font-size: 18px; width: 28px; text-align: center; }
.asset-item-name { flex: 1; font-size: 14px; font-weight: 500; }
.asset-item-balance { font-size: 14px; font-weight: 700; }
.asset-item-balance.income { color: var(--income); }
.asset-item-balance.expense { color: var(--expense); }

/* Recurring section */
.recurring-upcoming {
    padding: 8px 0;
}
.recurring-upcoming-title {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.recurring-upcoming-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--gray-50);
}
.recurring-up-icon { font-size: 18px; width: 28px; text-align: center; }
.recurring-up-info { flex: 1; }
.recurring-up-name { font-size: 14px; font-weight: 500; }
.recurring-up-date { font-size: 11px; color: var(--gray-400); }
.recurring-up-amount { font-size: 14px; font-weight: 700; color: var(--gray-700); }
.recurring-apply-btn {
    padding: 5px 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.recurring-apply-btn:active { background: var(--primary-dark); }

.recurring-list { padding: 4px 0; }
.recurring-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-50);
    transition: background 0.1s;
}
.recurring-item:active { background: var(--gray-50); }
.recurring-item.inactive { opacity: 0.5; }
.recurring-icon { font-size: 18px; width: 28px; text-align: center; }
.recurring-info { flex: 1; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.recurring-name { font-size: 14px; font-weight: 500; }
.recurring-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}
.inactive-badge {
    background: var(--gray-100);
    color: var(--gray-400);
}
.recurring-amount { font-size: 14px; font-weight: 700; }
.recurring-amount.expense { color: var(--expense); }
.recurring-amount.income { color: var(--income); }
.recurring-amount.transfer { color: var(--transfer); }

/* ═══════════════════════════════════════════
   예산 (inside More)
   ═══════════════════════════════════════════ */
.card-flat {
    background: var(--white);
    margin: 8px;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.bgt-total-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 12px;
}
.bgt-total-input-wrap { display: flex; gap: 6px; align-items: center; }
.bgt-inline-input {
    width: 120px;
    padding: 6px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
    text-align: right;
    outline: none;
}
.bgt-inline-input:focus { border-color: var(--primary); }
.bgt-save-btn {
    padding: 6px 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.bgt-total-bar-wrap { margin-top: 4px; }
.bgt-progress {
    height: 8px;
    background: var(--gray-100);
    border-radius: 4px;
    overflow: hidden;
}
.bgt-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}
.bgt-progress-label {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 4px;
    text-align: right;
}

.bgt-cat-section, .bgt-status-section { margin: 8px; }
.bgt-cat-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    padding: 8px 4px;
}
.bgt-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--white);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    box-shadow: var(--shadow);
}
.bgt-row-label { flex: 1; font-size: 13px; font-weight: 500; }
.bgt-row-input {
    width: 110px;
    padding: 5px 8px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    text-align: right;
    font-size: 13px;
    outline: none;
}
.bgt-row-input:focus { border-color: var(--primary); }
.bgt-row-save {
    padding: 5px 10px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}
.bgt-status-item {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 4px;
    box-shadow: var(--shadow);
}
.bgt-status-top {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 6px;
}
.bgt-status-name { font-weight: 600; }
.bgt-status-nums { color: var(--gray-500); }

/* ═══════════════════════════════════════════
   설정 섹션 (inside More)
   ═══════════════════════════════════════════ */
.set-section { margin: 4px 0; }
.set-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
}
.set-add-btn {
    padding: 4px 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.set-cat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-50);
    cursor: pointer;
    transition: background 0.1s;
}
.set-cat-item:active { background: var(--gray-50); }
.set-cat-icon { font-size: 20px; width: 30px; text-align: center; }
.set-cat-name { flex: 1; font-size: 14px; font-weight: 500; }
.set-cat-arrow { color: var(--gray-300); font-size: 16px; }
.set-cat-child {
    padding-left: 28px;
    background: var(--gray-50);
}
.set-cat-child .set-cat-name { font-size: 13px; color: var(--gray-600); }
.set-asset-group {
    font-size: 11px;
    color: var(--gray-400);
    font-weight: 400;
    margin-left: 4px;
}

.set-export { text-align: center; padding: 16px; }
.export-btn {
    padding: 10px 24px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--gray-600);
    cursor: pointer;
    font-weight: 500;
}

/* ═══════════════════════════════════════════
   하단 탭 바 (4탭 + 센터 FAB)
   ═══════════════════════════════════════════ */
.tab-bar {
    display: flex;
    height: var(--tab-height);
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    flex-shrink: 0;
    padding-bottom: var(--safe-bottom);
    position: relative;
}
.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    font-size: 10px;
    font-weight: 500;
    transition: color 0.15s;
    padding: 4px 0;
}
.tab.active { color: var(--primary); }
.tab-icon { width: 22px; height: 22px; }

/* Center FAB in tab bar */
.tab-fab-center {
    position: relative;
    flex: 1;
}
.fab-center-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 28px;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 4px 12px rgba(44,123,229,0.4);
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    transition: transform 0.15s, box-shadow 0.15s;
}
.tab-fab-center:active .fab-center-btn {
    transform: translateX(-50%) scale(0.92);
}

/* FAB 메뉴 */
.fab-backdrop {
    position: fixed;
    inset: 0;
    z-index: 49;
    background: rgba(0,0,0,0.2);
}
.fab-menu {
    position: fixed;
    bottom: calc(var(--tab-height) + var(--safe-bottom) + 16px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 51;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    animation: fabMenuIn 0.15s ease;
}
@keyframes fabMenuIn {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.fab-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--white);
    border: none;
    border-radius: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.1s;
}
.fab-menu-item:active { background: var(--gray-100); }
.fab-menu-icon { font-size: 16px; }

/* ═══════════════════════════════════════════
   모달 (바텀 시트) + 애니메이션
   ═══════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: modalFadeIn 0.2s ease;
}
@keyframes modalFadeIn {
    from { background: rgba(0,0,0,0); }
    to { background: rgba(0,0,0,0.35); }
}
.modal-sheet {
    background: var(--white);
    width: 100%;
    max-width: 500px;
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
    overflow-y: auto;
    animation: sheetUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    padding-bottom: var(--safe-bottom);
}
@keyframes sheetUp {
    from { transform: translateY(100%); opacity: 0.5; }
    to { transform: translateY(0); opacity: 1; }
}
.modal-handle {
    width: 36px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
    margin: 8px auto;
}
.modal-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 16px 12px;
    border-bottom: 1px solid var(--gray-100);
}
.modal-sheet-header h3 { font-size: 16px; font-weight: 600; }
.modal-cancel-btn, .modal-save-btn {
    background: none;
    border: none;
    font-size: 15px;
    cursor: pointer;
    padding: 4px 8px;
}
.modal-cancel-btn { color: var(--gray-500); }
.modal-save-btn { color: var(--primary); font-weight: 700; }

.modal-type-bar {
    display: flex;
    margin: 16px 16px 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--gray-200);
}
.mtype-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: var(--white);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color: var(--gray-400);
    transition: all 0.15s;
}
.mtype-btn.active[data-type="expense"] { background: var(--expense); color: #fff; }
.mtype-btn.active[data-type="income"] { background: var(--income); color: #fff; }
.mtype-btn.active[data-type="transfer"] { background: var(--transfer); color: #fff; }

.modal-amount-row {
    display: flex;
    align-items: center;
    padding: 20px 16px;
    gap: 8px;
}
.amount-currency { font-size: 28px; font-weight: 300; color: var(--gray-400); }
.amount-input {
    flex: 1;
    font-size: 32px;
    font-weight: 700;
    border: none;
    outline: none;
    color: var(--gray-900);
    background: transparent;
}
.amount-input::placeholder { color: var(--gray-300); }

.modal-field-list { border-top: 1px solid var(--gray-100); }
.mfield {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-50);
}
.mfield label {
    width: 70px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    flex-shrink: 0;
}
.mfield-input {
    flex: 1;
    font-size: 14px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--gray-800);
    text-align: right;
}
.mfield-input::placeholder { color: var(--gray-300); }
select.mfield-input { direction: rtl; }
select.mfield-input option { direction: ltr; }
select.mfield-input optgroup { font-style: normal; font-weight: 600; color: var(--gray-700); }
select.mfield-input optgroup option { font-weight: 400; }

/* Swap button */
.swap-btn {
    background: var(--transfer-bg);
    color: var(--transfer);
    border: 1px solid var(--transfer);
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-left: auto;
}

/* Action row (copy + delete) */
.modal-action-row {
    display: flex;
    gap: 8px;
    padding: 16px;
}
.modal-copy-btn {
    flex: 1;
    padding: 10px;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.modal-delete-btn {
    flex: 1;
    padding: 10px;
    background: none;
    border: 1px solid var(--expense);
    color: var(--expense);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.modal-delete-wrap { padding: 16px; text-align: center; }
.modal-delete-wrap .modal-delete-btn { width: 100%; }

/* ═══════════════════════════════════════════
   계산기 패드
   ═══════════════════════════════════════════ */
.calc-pad {
    display: none;
    padding: 8px 12px 12px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}
.calc-pad.visible {
    display: block;
    animation: fadeSlideDown 0.2s ease;
}
.calc-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}
.calc-row:last-child { margin-bottom: 0; }
.calc-btn {
    flex: 1;
    height: 44px;
    border: none;
    border-radius: 8px;
    background: var(--white);
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    transition: background 0.1s;
}
.calc-btn:active { background: var(--gray-100); }
.calc-op {
    background: var(--primary-light);
    color: var(--primary);
}
.calc-op:active { background: #d0e2ff; }
.calc-clear {
    background: var(--expense-bg);
    color: var(--expense);
}
.calc-eq {
    background: var(--primary);
    color: #fff;
}
.calc-eq:active { background: var(--primary-dark); }

/* ═══════════════════════════════════════════
   이모지 선택기
   ═══════════════════════════════════════════ */
.emoji-picker-sheet {
    background: var(--white);
    width: 100%;
    max-width: 500px;
    border-radius: 16px 16px 0 0;
    max-height: 60vh;
    overflow-y: auto;
    animation: sheetUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    padding-bottom: var(--safe-bottom);
}
.emoji-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 15px;
    font-weight: 600;
}
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    padding: 12px;
}
.emoji-btn {
    width: 100%;
    aspect-ratio: 1;
    border: none;
    background: var(--gray-50);
    border-radius: 8px;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s;
}
.emoji-btn:hover { background: var(--gray-200); }
.emoji-btn:active { background: var(--primary-light); }

/* Icon input cursor style */
.icon-input {
    cursor: pointer;
    font-size: 20px;
}

/* ═══════════════════════════════════════════
   토글 스위치
   ═══════════════════════════════════════════ */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    margin-left: auto;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--gray-300);
    border-radius: 24px;
    transition: 0.3s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ═══════════════════════════════════════════
   자산 상세 모달
   ═══════════════════════════════════════════ */
.asset-detail-content { padding: 0; }
.ad-balance-card {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-light), var(--white));
    margin: 8px;
    border-radius: var(--radius);
}
.ad-balance-amount {
    font-size: 28px;
    font-weight: 700;
}
.ad-balance-amount.income { color: var(--income); }
.ad-balance-amount.expense { color: var(--expense); }
.ad-balance-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}
.ad-chart-wrap {
    background: var(--white);
    padding: 16px;
    margin: 8px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.ad-chart-wrap canvas { max-height: 200px; }
.ad-txn-list { padding: 0; }
.ad-txn-title {
    padding: 12px 16px 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-600);
}

/* ═══ 토스트 ═══ */
.toast-container {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--gray-800);
    color: #fff;
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: toastFade 0.25s ease;
    white-space: nowrap;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--expense); }
@keyframes toastFade {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════
   대량 입력 모달
   ═══════════════════════════════════════════ */
.bulk-sheet {
    max-width: 700px;
    max-height: 95vh;
}
.bulk-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    flex-wrap: wrap;
}
.bulk-type-bar {
    display: flex;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--gray-200);
}
.bulk-type-bar .mtype-btn { padding: 7px 16px; font-size: 13px; }
.bulk-default-date {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--gray-500);
    margin-left: auto;
}
.bulk-date-input {
    padding: 5px 8px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}
.bulk-date-input:focus { border-color: var(--primary); }

/* Paste zone */
.bulk-paste-zone { border-bottom: 1px solid var(--gray-100); }
.bulk-paste-toggle { padding: 8px 16px; text-align: center; }
.bulk-paste-btn {
    padding: 8px 20px;
    background: var(--gray-50);
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.15s;
}
.bulk-paste-btn:hover { background: var(--income-bg); border-color: var(--primary); color: var(--primary); }
.bulk-paste-area {
    padding: 0 16px 12px;
    animation: fadeSlideDown 0.2s ease;
}
@keyframes fadeSlideDown {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 300px; }
}
.bulk-paste-help {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 8px;
    line-height: 1.6;
}
.bulk-paste-format {
    display: inline-block;
    margin-top: 2px;
    padding: 2px 8px;
    background: var(--gray-100);
    border-radius: 4px;
    font-family: monospace;
    font-size: 11px;
    color: var(--gray-600);
}
.bulk-paste-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: monospace;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    background: var(--gray-50);
    color: var(--gray-800);
    tab-size: 16;
}
.bulk-paste-textarea:focus { border-color: var(--primary); background: #fff; }
.bulk-paste-textarea::placeholder { color: var(--gray-400); }
.bulk-paste-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
}
.bulk-paste-apply {
    padding: 7px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.bulk-paste-apply:active { background: var(--primary-dark); }
.bulk-paste-cancel {
    padding: 7px 16px;
    background: var(--white);
    color: var(--gray-500);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.bulk-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(95vh - 230px);
    overflow-y: auto;
}
.bulk-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.bulk-table thead { position: sticky; top: 0; z-index: 1; }
.bulk-table th {
    background: var(--gray-50);
    padding: 8px 6px;
    text-align: left;
    font-weight: 600;
    color: var(--gray-500);
    font-size: 12px;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}
.bulk-th-date { width: 120px; }
.bulk-th-cat { width: 130px; }
.bulk-th-asset { width: 120px; }
.bulk-th-amount { width: 110px; }
.bulk-th-desc { }
.bulk-th-del { width: 36px; }

.bulk-table td {
    padding: 4px 4px;
    border-bottom: 1px solid var(--gray-50);
    vertical-align: middle;
}
.bulk-table input,
.bulk-table select {
    width: 100%;
    padding: 8px 6px;
    border: 1px solid var(--gray-100);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    background: var(--white);
}
.bulk-table input:focus,
.bulk-table select:focus { border-color: var(--primary); background: #f8faff; }
.bulk-table input[type="number"] { text-align: right; }
.bulk-row-del {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--gray-400);
    padding: 4px;
    border-radius: 4px;
}
.bulk-row-del:hover { color: var(--expense); background: var(--expense-bg); }

.bulk-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid var(--gray-100);
    background: var(--white);
    position: sticky;
    bottom: 0;
}
.bulk-add-row-btn {
    padding: 8px 16px;
    background: var(--gray-100);
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    cursor: pointer;
}
.bulk-add-row-btn:active { background: var(--gray-200); }
.bulk-summary {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
}
.bulk-summary span { font-weight: 700; color: var(--gray-700); }

/* ═══════════════════════════════════════════
   데스크톱 대응 (500px 이상)
   ═══════════════════════════════════════════ */
@media (min-width: 501px) {
    .app {
        border-left: 1px solid var(--gray-200);
        border-right: 1px solid var(--gray-200);
    }
}

/* ═══ 작은 화면 대응 ═══ */
@media (max-width: 360px) {
    .cal-day { min-height: 50px; }
    .cal-amt { font-size: 8px; }
    .cal-num { font-size: 11px; }
    .emoji-grid { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 500px) {
    .bulk-sheet { max-width: 100%; }
    .bulk-th-date { width: 100px; }
    .bulk-th-cat { width: 110px; }
    .bulk-th-asset { width: 100px; }
    .bulk-th-amount { width: 90px; }
}
