
:root {
    --primary: #007bff;
    --secondary: #6f42c1;
    --success: #28a745;
    --danger: #dc3545;
    --bg: #f0f2f5;
    --card-bg: #fff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    margin: 0;
    padding: 0 0 80px 0;
    color: #333;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 65px;
    background: #fff;
    display: flex;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #888;
    cursor: pointer;
}

.nav-item.active {
    color: var(--primary);
    font-weight: bold;
}

.nav-icon {
    font-size: 22px;
    margin-bottom: 2px;
}

.page {
    display: none;
    padding: 15px;
    max-width: 500px;
    margin: auto;
}

.page.active {
    display: block;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 15px;
}

h2 {
    font-size: 1.1em;
    margin: 0 0 15px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

label {
    display: block;
    margin: 12px 0 6px;
    font-weight: bold;
    font-size: 0.85em;
    color: #555;
}

select,
input,
button {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #ddd;
    font-size: 16px;
    box-sizing: border-box;
}

.item-row {
    display: flex;
    align-items: center;
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    gap: 10px;
    border: 1px solid #eee;
}

.item-info {
    flex: 1;
    font-size: 0.9em;
    font-weight: bold;
}

.qty-input {
    width: 80px !important;
    padding: 6px !important;
    text-align: center;
}

.del-btn {
    width: auto !important;
    background: var(--danger);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8em;
}

.history-card {
    border-left: 5px solid #ddd;
    margin-bottom: 10px;
    padding: 12px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    position: relative;
}

.history-card.paid {
    border-left-color: var(--primary);
}

.history-card.free {
    border-left-color: var(--success);
}

.h-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75em;
    color: #999;
    margin-bottom: 6px;
}

.h-date-display {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 4px;
    color: #555;
    font-weight: bold;
    cursor: pointer;
}

.h-del-x {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #fee2e2;
    border: none;
    color: var(--danger);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 14px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.grade-badge {
    position: absolute;
    top: 40px;
    right: 12px;
    font-size: 1.4em;
    font-weight: 900;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-box {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #eee;
    text-align: center;
}

.stat-label {
    font-size: 0.7em;
    color: #777;
    display: block;
    margin-bottom: 4px;
}

.stat-val {
    font-size: 1em;
    font-weight: bold;
}

.chart-container {
    position: relative;
    height: 180px;
    width: 100%;
    margin: 10px 0;
}

.btn {
    border: none;
    font-weight: bold;
    padding: 12px;
    cursor: pointer;
    border-radius: 8px;
    margin-top: 10px;
}

.btn-main {
    background: var(--primary);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

/* カレンダーを画面中央表示 */
.flatpickr-calendar {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 9999 !important;
}

/* スマホサイズでも中央に */
@media (max-width: 600px) {
    .flatpickr-calendar {
        width: 90% !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
    }
}