:root {
    --primary: #007AFF; --bg: #F2F4F8; --card-bg: #FFFFFF;
    --text-main: #1C1C1E; --text-sub: #8E8E93; --danger: #FF3B30; --success: #34C759;
    --radius: 16px; --shadow: 0 4px 15px rgba(0,0,0,0.05);
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0; background-color: var(--bg); color: var(--text-main);
    padding-bottom: 100px; padding-top: env(safe-area-inset-top); -webkit-tap-highlight-color: transparent;
}
.container { max-width: 900px; margin: 0 auto; padding-top: 20px; padding-bottom: 90px; }
.dashboard-grid, .work-grid { display: grid; grid-template-columns: 1fr; gap: 15px; padding: 0 15px; margin-bottom: 15px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 15px; margin-bottom: 15px; }
.limit-width-content { max-width: 600px; margin: 0 auto; padding: 0 15px; }
@media(min-width: 768px) { .dashboard-grid { grid-template-columns: 1fr 1fr; } .work-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); } }

.section-header { display: flex; justify-content: space-between; align-items: center; padding: 0 20px; margin-bottom: 10px; }
.section-title { font-size: 1.0rem; font-weight: bold; color: var(--text-sub); }
select.month-selector { background: transparent; border: none; font-size: 1.1rem; font-weight: bold; color: var(--primary); outline: none; text-align: right; cursor: pointer; }

/* カレンダー */
.calendar-wrapper { background: var(--card-bg); margin: 0; border-radius: var(--radius); padding: 15px; box-shadow: var(--shadow); }
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: bold; font-size: 1.1rem; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; text-align: center; font-size: 0.85rem; }
.cal-day-head { font-size: 0.75rem; margin-bottom: 5px; font-weight: bold; }
.cal-day { position: relative; padding: 6px 0; border-radius: 8px; cursor: pointer; transition: background 0.2s; }
.cal-day:active { background: #eee; }
.cal-day.selected { background: #E3F2FD; border: 1px solid var(--primary); font-weight: bold; color: var(--primary); }
.cal-dots { display: flex; justify-content: center; gap: 4px; margin-top: 2px; height: 6px; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; }
.cal-dot.actual { background: var(--primary); }
.cal-dot.plan { background: #FF9500; }

/* 共通カード */
.work-card { background: var(--card-bg); margin: 0; border-radius: var(--radius); box-shadow: var(--shadow); position: relative; }
.card-planned { opacity: 0.85; border: 2px dashed var(--primary); }
.badge-planned { background: #FF9500; color: white; font-size: 0.65rem; padding: 3px 6px; border-radius: 4px; vertical-align: middle; margin-right: 6px; font-weight:bold; }
.card-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; border-radius: 16px 16px 0 0; }
.card-body { padding: 15px 20px; border-radius: 0 0 16px 16px; }
.tag-badge { background: #E5E5EA; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; color: #333; margin-left:6px;}

.detail-box { background: #FAFAFA; border-radius: 12px; padding: 12px; display: grid; grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)); gap: 8px; margin-bottom: 12px; border: 1px solid #eee; }
.detail-item { display: flex; flex-direction: column; align-items: center; }
.detail-label { font-size: 0.65rem; color: #999; margin-bottom: 2px; }
.detail-val { font-size: 0.9rem; font-weight: 500; color: #333; }
.detail-val.blue { color: var(--primary); font-weight: 600; }
.total-row { display: flex; justify-content: space-between; align-items: flex-end; }
.total-amount { font-size: 1.3rem; font-weight: bold; color: #1C1C1E; line-height: 1; }

.icon-btn { border: none; background: none; font-size: 1.1rem; color: inherit; opacity: 0.6; padding: 0; cursor: pointer; }
.btn-detail { background: #E3F2FD; color: var(--primary); border: none; padding: 8px; border-radius: 8px; font-size: 0.85rem; font-weight: bold; cursor: pointer; display: flex; align-items: center; justify-content:center; gap: 4px; flex:1; text-decoration: none;}

/* ボトムナビ */
.bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 900px; height: 65px; background: rgba(255,255,255,0.98); backdrop-filter: blur(10px); border-top: 1px solid #eee; display: flex; justify-content: space-around; align-items: center; z-index: 100; padding-bottom: env(safe-area-inset-bottom); }
.nav-btn { flex: 1; text-align: center; font-size: 0.75rem; color: #ccc; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; font-weight:bold; text-decoration:none; }
.nav-btn.active { color: var(--primary); }
.nav-fab-wrapper { display: flex; justify-content: center; align-items: center; height: 100%; margin: 0 5px; }
.nav-fab { width: 44px; height: 44px; background: var(--primary); border-radius: 14px; display: flex; justify-content: center; align-items: center; color: white; font-size: 1.8rem; box-shadow: 0 4px 10px rgba(0,122,255,0.3); cursor: pointer; }

/* モーダル */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 300; justify-content: center; align-items: flex-end; }
.modal.active { display: flex; }
.modal-content { background: white; width: 100%; max-width: 500px; border-radius: 20px 20px 0 0; padding: 0; box-shadow: 0 -5px 20px rgba(0,0,0,0.1); animation: slideUp 0.3s ease; max-height: 90vh; overflow-y: auto; display:flex; flex-direction:column; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header-bg { padding: 20px 25px 10px; border-radius: 20px 20px 0 0; background: #fff; position: sticky; top:0; z-index: 10; box-shadow: 0 2px 5px rgba(0,0,0,0.05);}
.modal-body { padding: 15px 25px 25px; flex-grow: 1; }
.form-row { display: flex; gap: 10px; margin-bottom: 15px; }
.form-group { flex: 1; position: relative; }
.form-label { display: block; font-size: 0.8rem; color: #888; margin-bottom: 5px; font-weight: bold; }
.form-control { width: 100%; padding: 12px; border: 1px solid #E5E5EA; border-radius: 12px; font-size: 1.05rem; box-sizing: border-box; background: #F9F9F9; }
.toggle-box { padding: 12px; background: #f2f4f8; border-radius: 12px; display: flex; align-items: center; gap: 8px; font-size: 0.95rem; font-weight: 500;}
.modal-btns { display: flex; gap: 10px; margin-top: 25px; position: sticky; bottom: -10px; background: white; padding-top: 10px;}
.btn { flex: 1; padding: 14px; border: none; border-radius: 10px; font-weight: bold; cursor: pointer; font-size: 1rem;}
.btn-cancel { background: #F2F2F7; color: #888; }
.btn-submit { background: var(--primary); color: white; }

/* その他 */
.tab-btn { flex: 1; padding: 10px; border-radius: 8px; font-weight: bold; border: none; cursor: pointer; font-size: 0.9rem;}
.tab-active { background: var(--primary); color: white; }
.tab-inactive { background: #f0f0f5; color: #888; }
.dropdown { position: relative; }
.dropdown-content { display: none; position: absolute; right: 0; top: 100%; background-color: #fff; min-width: 180px; box-shadow: 0px 8px 16px rgba(0,0,0,0.15); z-index: 50; border-radius: 12px; border: 1px solid #eee; overflow: hidden; }
.dropdown-content.show { display: block; }
.dropdown-item { padding: 12px 16px; display: flex; align-items: center; gap: 8px; color: #333; font-size: 0.95rem; cursor: pointer; border-bottom: 1px solid #f0f0f5; background: #fff; border:none; width:100%; text-align:left; font-weight:bold; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.success { color: var(--success); }
.suggestions-box { position: absolute; top: 100%; left: 0; width: 100%; background: white; border: 1px solid #ddd; border-radius: 10px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); z-index: 300; max-height: 150px; overflow-y: auto; display: none; margin-top: 4px; }
.suggestion-item { padding: 12px; border-bottom: 1px solid #eee; cursor: pointer; }
.settings-group { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0 20px; margin: 0 0 20px 0; }
.settings-item { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; border-bottom: 1px solid #eee; }
.settings-item:last-child { border-bottom: none; }
.settings-input { text-align: right; border: none; background: #f2f4f8; border-radius: 6px; padding: 8px 12px; font-size: 1rem; width: 130px; outline: none; }

/* 進捗用 */
.status-card { background: var(--card-bg); margin: 0; padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); }
.status-row { margin-bottom: 25px; } .status-row:last-child { margin-bottom: 0; }
.status-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.status-label { font-size: 0.9rem; font-weight: bold; color: var(--text-sub); }
.progress-track { height: 12px; background: #EEF1F5; border-radius: 6px; overflow: hidden; position: relative; margin-bottom: 6px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%); width: 0%; transition: width 0.6s ease; border-radius: 6px; }
.status-val-row { display: flex; justify-content: space-between; align-items: center; }
.current-val { font-weight: bold; font-size: 1.1rem; }
.remaining-text { font-size: 0.85rem; font-weight: 600; color: var(--primary); }
.remaining-text.alert { color: var(--danger); }
.analysis-item { background: #fff; padding: 15px; border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; display: flex; flex-direction: column; justify-content: center;}
.analysis-label { font-size: 0.75rem; color: var(--text-sub); margin-bottom: 5px; font-weight: bold;}
.analysis-val { font-size: 1.1rem; font-weight: bold; color: #333; }
.analysis-sub { font-size: 0.65rem; color: #888; margin-top: 4px; }
.chart-wrapper { background: #fff; padding: 15px; border-radius: var(--radius); box-shadow: var(--shadow); height: 250px; position: relative; margin: 0 0 15px 0; }