:root {
    --bg-color: #121212;         
    --card-bg: #1e1e1e;          
    --text-main: #e0e0e0;        
    --text-sub: #a0a0a0;         
    --accent-red: #e84118;       
    --accent-blue: #4ECDC4;      
    --color-tax: #7f8c8d;        
    --border-color: #333333;     
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow-y: auto; 
    padding-bottom: env(safe-area-inset-bottom);
    -webkit-tap-highlight-color: transparent;
}

.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.fade-in-view { animation: fadeIn 0.4s ease-out; }

.header {
    position: sticky; top: 0; z-index: 100; background: var(--card-bg); padding: 15px 20px;
    display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.header h1 { margin: 0; font-size: 1.3rem; font-weight: 700; color: var(--text-main); }
.header-actions { display: flex; gap: 20px; }
.icon-btn { font-size: 1.3rem; color: var(--text-sub); cursor: pointer; transition: transform 0.2s, color 0.2s; position: relative; }
.icon-btn:active { transform: scale(0.9); }
.icon-btn.active { color: var(--text-main); transform: scale(1.1); }
.icon-btn.active::after {
    content: ''; position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%);
    width: 4px; height: 4px; background: var(--accent-red); border-radius: 50%;
}

.sync-status { font-size: 0.7rem; color: var(--text-sub); margin-right: auto; margin-left: 15px; opacity: 0; transition: opacity 0.3s; }
.sync-status.show { opacity: 1; }

.content-wrapper { padding: 0 20px 40px 20px; max-width: 600px; margin: 0 auto; }
.summary-view { display: block; }
.date-nav-wrapper { background: var(--card-bg); padding: 10px 0; position: sticky; top: 60px; z-index: 90; width: 100%; overflow: hidden; }
.date-nav { display: flex; overflow-x: auto; white-space: nowrap; padding: 0 20px; -webkit-overflow-scrolling: touch; }
.date-nav span { display: inline-block; flex: 0 0 auto; margin-right: 25px; padding-bottom: 8px; cursor: pointer; color: var(--text-sub); font-weight: bold; font-size: 0.95rem; transition: color 0.2s, transform 0.2s; }
.date-nav span:active { transform: scale(0.95); }
.date-nav span:last-child { margin-right: 40px; }
.date-nav span.active { color: var(--text-main); border-bottom: 3px solid transparent; }

.toggle-container { background: var(--card-bg); padding: 10px 0 25px 0; display: flex; justify-content: center; gap: 15px; border-bottom-left-radius: 20px; border-bottom-right-radius: 20px; margin-bottom: 20px; }
.toggle-btn { padding: 8px 30px; border-radius: 30px; font-size: 0.9rem; cursor: pointer; color: var(--text-sub); font-weight: bold; background: #2a2a2a; transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1); user-select: none; }
.toggle-btn:active { transform: scale(0.92); opacity: 0.8; }
.toggle-btn.active { color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }

.dashboard-top { display: flex; align-items: center; justify-content: space-between; background: var(--card-bg); border-radius: 16px; padding: 25px; margin-bottom: 25px; box-shadow: 0 4px 15px rgba(0,0,0,0.3); animation: slideInUp 0.5s ease-out; }
.chart-area { position: relative; width: 130px; height: 130px; }
.stats-area { flex: 1; padding-left: 30px; text-align: right; }
.stat-row { margin-bottom: 12px; }
.stat-label { font-size: 0.8rem; color: var(--text-sub); margin-bottom: 4px; }
.stat-value { font-size: 1.2rem; font-weight: bold; letter-spacing: 0.5px; }
.stat-diff { font-size: 0.75rem; color: var(--text-sub); margin-top: 2px; font-weight: normal; }
.val-income { color: var(--accent-blue); } 
.val-expense { color: var(--accent-red); }
.val-balance { color: var(--text-main); }

.category-item { background: var(--card-bg); border-radius: 16px; padding: 18px; margin-bottom: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.2); cursor: pointer; transition: transform 0.2s, background-color 0.2s; opacity: 0; }
.category-item.animate-in { animation: slideInUp 0.5s ease-out forwards; }
.category-item:active { transform: scale(0.97); background: #252525; }
.cat-header { display: flex; align-items: center; }
.icon-box { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-right: 15px; font-size: 1.1rem; color: #fff; transition: transform 0.3s; }
.category-item:hover .icon-box { transform: rotate(10deg) scale(1.1); }
.cat-info { flex: 1; }
.cat-name { font-weight: bold; font-size: 1rem; color: var(--text-main); }
.cat-total { font-size: 1.1rem; font-weight: bold; color: var(--text-main); }
.cat-percent-val { font-size: 0.75rem; color: var(--text-sub); text-align: right; }
.sub-list { margin-top: 12px; padding-top: 8px; border-top: 1px solid #333; padding-left: 57px; }
.sub-item { display: flex; justify-content: space-between; padding: 6px 0; font-size: 0.85rem; color: var(--text-sub); }

.trend-view { display: none; padding-top: 20px; }
.trend-card { background: var(--card-bg); border-radius: 16px; padding: 20px; margin-bottom: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.3); animation: slideInUp 0.5s ease-out; }
.trend-title { font-size: 1rem; font-weight: bold; margin-bottom: 15px; color: var(--text-sub); text-align: center; }
.scrollable-chart-container { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart-inner { height: 300px; }

.detail-view { display: none; padding-top: 20px; padding-bottom: 80px; }
.detail-title-header { font-size: 1.1rem; font-weight: bold; text-align: center; margin-bottom: 20px; color: var(--text-main); animation: fadeIn 0.5s; }
.detail-list { background: var(--card-bg); border-radius: 16px; overflow: hidden; animation: slideInUp 0.4s ease-out; }
.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 15px; border-bottom: 1px solid #333; opacity: 0; animation: fadeIn 0.3s ease-out forwards; }
.detail-row:last-child { border-bottom: none; }
.detail-left { display: flex; flex-direction: column; gap: 4px; }
.detail-date { font-size: 0.75rem; color: var(--text-sub); }
.detail-desc { font-size: 0.95rem; color: var(--text-main); font-weight: 500; }
.detail-amount { font-size: 1rem; font-weight: bold; }

.back-btn-container { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 0; width: 100%; display: flex; justify-content: center; z-index: 200; pointer-events: none; animation: fadeIn 0.5s 0.2s backwards; }
.back-btn { pointer-events: auto; background: #333; color: #fff; padding: 12px 40px; border-radius: 30px; border: 1px solid #555; font-weight: bold; box-shadow: 0 4px 10px rgba(0,0,0,0.5); cursor: pointer; display: flex; align-items: center; gap: 8px; transition: 0.2s; user-select: none; }
.back-btn:active { transform: scale(0.92); background: #444; opacity: 0.8; }

.no-data { text-align: center; padding: 40px 0; color: var(--text-sub); }
#loader { text-align: center; margin-top: 60px; color: var(--text-sub); }

/*パスワード画面用*/
.password-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-color); z-index: 9999;
    display: flex; justify-content: center; align-items: center;
}
.password-box {
    background: var(--card-bg); padding: 30px; border-radius: 16px;
    text-align: center; box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    width: 80%; max-width: 350px;
}
.password-box h2 {
    margin-top: 0; color: var(--text-main); font-size: 1.2rem; margin-bottom: 20px;
}
.password-box input {
    padding: 12px; border-radius: 8px; border: 1px solid var(--border-color);
    background: #2a2a2a; color: white; margin-bottom: 15px; width: 100%;
    box-sizing: border-box;
}
.password-box button {
    background: var(--accent-blue); color: #000; font-weight: bold;
    border: none; padding: 12px 0; border-radius: 8px; cursor: pointer;
    width: 100%; transition: opacity 0.2s;
}
.password-box button:active { opacity: 0.8; }
#password-error {
    color: var(--accent-red); font-size: 0.85rem; margin-top: 15px; display: none;
}