/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
    padding-bottom: 2rem;
}
a { color: #4A90D9; text-decoration: none; }

/* ===== Navbar ===== */
.navbar {
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar-inner {
    max-width: 780px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
}
.nav-logo { font-size: 1.1rem; font-weight: 700; color: #333; }
.nav-links { display: flex; gap: 0.5rem; }
.nav-link {
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #555;
    transition: background 0.2s;
}
.nav-link:hover, .nav-link.active { background: #eaf2fc; color: #4A90D9; font-weight: 600; }

/* ===== Container ===== */
.container { max-width: 780px; margin: 0 auto; padding: 1rem; }

/* ===== Section Title ===== */
.section-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.75rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }

/* ===== Cards ===== */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding: 1rem;
    margin-bottom: 1rem;
}

/* ===== Stat Cards Grid ===== */
.card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-bottom: 1.25rem; }
.stat-card { text-align: center; padding: 0.9rem 0.5rem; }
.stat-card-highlight { background: linear-gradient(135deg, #fff3e0, #fff8e1); border: 1.5px solid #FFE082; }
.stat-icon { font-size: 1.5rem; margin-bottom: 0.25rem; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: #222; }
.stat-value-sm { font-size: 1.3rem; color: #E65100; }
.stat-label { font-size: 0.78rem; color: #888; margin-top: 0.15rem; }

/* ===== Charts ===== */
.chart-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1.25rem; }
.chart-card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.6rem; color: #444; }
.chart-container { position: relative; width: 100%; height: 220px; }
.chart-container canvas { display: block; }
.empty-state { text-align: center; color: #aaa; padding: 2rem; font-size: 0.9rem; }

/* ===== Table ===== */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.records-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.records-table th { text-align: left; padding: 0.6rem 0.5rem; color: #888; font-weight: 600; border-bottom: 2px solid #eee; }
.records-table td { padding: 0.55rem 0.5rem; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.records-table tr:last-child td { border-bottom: none; }
.loading-cell { text-align: center; color: #aaa; padding: 1.5rem !important; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: #4A90D9; color: #fff; }
.btn-primary:hover { background: #3a7bc8; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; background: #e8ecf0; color: #555; }
.btn-block { width: 100%; margin-top: 0.75rem; }
.btn-danger { background: #D0021B; color: #fff; padding: 0.25rem 0.6rem; font-size: 0.78rem; border-radius: 6px; }
.btn-danger:hover { background: #b80118; }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.modal {
    background: #fff;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.25s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1rem 0.5rem; }
.modal-header h3 { font-size: 1.05rem; }
.btn-close { background: none; border: none; font-size: 1.4rem; color: #999; cursor: pointer; }
.modal-body { padding: 0.5rem 1rem 1.25rem; }

/* ===== Tabs ===== */
.tab-bar { display: flex; gap: 0; border-bottom: 2px solid #eee; margin-bottom: 1rem; }
.tab-btn {
    flex: 1;
    padding: 0.55rem;
    background: none;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    color: #999;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}
.tab-btn.active { color: #4A90D9; border-bottom-color: #4A90D9; }

/* ===== Forms ===== */
.form-group { margin-bottom: 0.85rem; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 600; color: #555; margin-bottom: 0.25rem; }
.form-group input, .form-group select {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    background: #fafafa;
    transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #4A90D9;
    background: #fff;
}

/* ===== Toast（带颜色 + 淡入淡出） ===== */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    white-space: nowrap;
}
.toast.toast-show { opacity: 1; visibility: visible; }
.toast-info { background: #333; color: #fff; }
.toast-success { background: #2E7D32; color: #fff; }
.toast-error { background: #C62828; color: #fff; }

/* ===== Custom Confirm Box ===== */
#confirmModal {
    align-items: center;
}
.confirm-box {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    width: 90%;
    max-width: 320px;
    text-align: center;
    animation: slideUp 0.2s ease-out;
}
.confirm-box p {
    font-size: 1rem;
    margin-bottom: 1.2rem;
    color: #333;
}
.confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}
.confirm-actions .btn {
    flex: 1;
    padding: 0.6rem;
}
.confirm-actions .btn-sm {
    background: #e8ecf0;
    color: #555;
}
.confirm-actions .btn-danger {
    background: #D0021B;
    color: #fff;
    font-size: 0.85rem;
    padding: 0.6rem;
    border-radius: 8px;
}

/* ===== Pull-to-Refresh ===== */
.pull-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-40px);
    z-index: 150;
    background: #fff;
    border-radius: 20px;
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
    color: #888;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: none;
    align-items: center;
    gap: 0.4rem;
    transition: transform 0.1s, opacity 0.1s;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed; inset: 0;
    background: rgba(255,255,255,0.7);
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
}
.loading-spinner {
    width: 36px; height: 36px;
    border: 3px solid #eee;
    border-top-color: #4A90D9;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Responsive ===== */
@media (min-width: 640px) {
    .chart-grid { grid-template-columns: repeat(2, 1fr); }
}
