/* ==========================================================================
   全新重構 UI/UX 樣式檔 (v16.2.2 深度最佳化 - 儀錶板橫向縮減高度版)
   ========================================================================== */

:root {
    /* 現代化亮色模式色彩組合 */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #f0f6ff;
    --secondary: #64748b;
    --success: #10b981;
    --success-light: #ecfdf5;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --input-bg: #f8fafc;
    --input-focus: rgba(37, 99, 235, 0.15);
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.03);
    --shadow-premium: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 10px 10px -5px rgba(15, 23, 42, 0.04);
}

/* OLED 精緻深色模式 */
[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-dark: #60a5fa;
    --primary-light: #1e293b;
    --secondary: #94a3b8;
    --success: #10b981;
    --success-light: #064e3b;
    --danger: #f87171;
    --danger-light: #450a0a;
    --warning: #fbbf24;
    --warning-light: #78350f;
    
    --bg-color: #0b0f19;
    --card-bg: #151f32;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #1e293b;
    --input-bg: #1e293b;
    --input-focus: rgba(59, 130, 246, 0.25);
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
}

body {
    font-family: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    padding-bottom: 60px; 
    transition: background-color 0.35s ease, color 0.35s ease;
    line-height: 1.5;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0;
}

/* 頂部導覽美化 */
.header {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
    color: white;
    padding: 24px 20px;
    text-align: center;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .header {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-bottom: 1px solid var(--border);
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 70%);
    pointer-events: none;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.header h1 { 
    font-size: 1.4rem; 
    font-weight: 800; 
    margin: 0; 
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.moto-icon {
    font-size: 1.6rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* 數據儀表板 - 微玻璃質感 */
.dashboard {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 16px 20px;
    background: var(--card-bg);
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.3s;
    border-bottom: 1px solid var(--border);
}

/* 數據卡片：改為橫向雙欄佈局 (CSS Grid) 降低高度並靠左對齊 */
.stat-card {
    background: var(--bg-color);
    padding: 12px;
    border-radius: 16px;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s;
    
    /* 雙欄佈局：左邊圖示，右邊文字與數據 */
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 10px;
    row-gap: 2px;
    align-items: center;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* 左側圓形底圈圖示 */
.stat-icon {
    grid-column: 1;
    grid-row: 1 / span 2;
    font-size: 1.25rem;
    margin-bottom: 0; /* 移除舊有的底部 margin */
    background: var(--card-bg);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.stat-card h3 { 
    grid-column: 2;
    grid-row: 1;
    font-size: 0.75rem; 
    color: var(--text-muted); 
    margin-bottom: 0;
    font-weight: 700;
    text-align: left;
}

.value-group {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* 靠左排列 */
}

.stat-card .value { 
    font-size: 1.25rem; 
    font-weight: 800; 
    color: var(--primary); 
    line-height: 1.1;
    font-family: 'Inter', sans-serif;
    text-align: left;
}

.stat-card .subtitle { 
    font-size: 0.68rem; 
    color: var(--text-muted); 
    margin-top: 1px; 
    font-weight: 500;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

/* 當保養已過期時，卡片紅暈警示 */
#maintCard {
    position: relative;
    overflow: hidden;
}

/* Tabs 精緻滾動 */
.tabs-wrapper {
    position: sticky;
    top: 0;
    background: var(--bg-color);
    z-index: 90;
    padding: 12px 16px;
    margin-bottom: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid transparent;
}

.tabs {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-button {
    padding: 10px 18px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 30px;
    font-size: 0.9rem;
    color: var(--text-muted);
    white-space: nowrap;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    flex-shrink: 0;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.tab-button:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.tab-button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    transform: translateY(-1px);
}

.content { padding: 0 16px 16px 16px; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Form Card 動態特效 */
.form-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 24px;
    border: 1px solid var(--border);
    transition: background-color 0.3s, border-color 0.3s;
}

.form-card h3 { 
    color: var(--text-main); 
    font-size: 1.15rem; 
    margin-bottom: 20px; 
    border-left: 5px solid var(--primary); 
    padding-left: 12px; 
    font-weight: 700;
}

.form-group { margin-bottom: 20px; }
.form-group label { 
    display: block; 
    margin-bottom: 8px; 
    font-weight: 600; 
    font-size: 0.9rem; 
    color: var(--text-main); 
}

.form-tip {
    display: block;
    margin-top: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.row-group { display: flex; gap: 16px; }
.row-group .half { flex: 1; min-width: 0; }

/* 輸入框美化與前後綴結合 */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

input, select, textarea {
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 0.95rem;
    background: var(--input-bg);
    color: var(--text-main);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    box-shadow: var(--shadow-sm);
    -webkit-appearance: none; 
}

input:focus, select:focus, textarea:focus { 
    outline: none; 
    border-color: var(--primary); 
    background: var(--card-bg);
    box-shadow: 0 0 0 4px var(--input-focus); 
}

.input-wrapper input {
    padding-right: 50px; /* 保留右側單位空間 */
}

.input-suffix {
    position: absolute;
    right: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    pointer-events: none;
}

/* 擬真數位電量格選擇器 */
.battery-selector { 
    display: flex; 
    gap: 8px; 
    justify-content: space-between; 
}

.battery-option { flex: 1; }
.battery-option input { display: none; }
.battery-option label {
    display: block;
    width: 100%;
    padding: 12px 0;
    text-align: center;
    background: var(--input-bg);
    border-radius: 12px;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1.5px solid var(--border);
    font-family: 'Inter', sans-serif;
    font-size: 1.05rem;
}

.battery-option label:hover {
    border-color: var(--success);
    color: var(--success);
}

.battery-option input:checked + label { 
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white; 
    border-color: #059669; 
    transform: scale(1.06); 
    box-shadow: 0 6px 15px rgba(16, 185, 129, 0.35); 
}

/* 快速地點晶片 */
.quick-stations { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.station-btn {
    padding: 12px 6px;
    border: 1.5px solid var(--border);
    background: var(--input-bg);
    border-radius: 12px;
    font-size: 0.88rem;
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.station-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.station-btn.active { 
    border-color: var(--primary); 
    background: var(--primary); 
    color: white; 
    font-weight: bold; 
    box-shadow: var(--shadow-md);
}

/* 高級按鈕 */
.btn {
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    padding: 10px 16px;
    font-size: 0.95rem;
    gap: 8px;
    box-shadow: var(--shadow-sm);
}

.btn:active { transform: scale(0.97); }
.btn-lg { padding: 15px 24px; font-size: 1.05rem; }
.btn-sm { padding: 8px 14px; font-size: 0.82rem; border-radius: 8px; }
.btn-full { width: 100%; }

.btn-primary { 
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); 
    color: white; 
    box-shadow: 0 4px 12px rgba(37,99,235,0.25); 
}
.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(37,99,235,0.35);
}

.btn-success { 
    background: linear-gradient(135deg, #10b981 0%, #059669 100%); 
    color: white; 
    box-shadow: 0 4px 12px rgba(16,185,129,0.25); 
}
.btn-success:hover {
    box-shadow: 0 6px 16px rgba(16,185,129,0.35);
}

.btn-secondary { 
    background: var(--input-bg); 
    color: var(--text-main); 
    border: 1.5px solid var(--border);
}
.btn-secondary:hover {
    background: var(--border);
}

.btn-danger { 
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); 
    color: white; 
}
.btn-warning { 
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); 
    color: white; 
}
.btn-text { background: none; color: var(--secondary); box-shadow: none; border-radius: 8px; }
.btn-block-setting { min-height: 52px; font-size: 0.98rem; border-radius: 14px; }

/* 滾動膠囊晶片 */
.scroll-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}
.scroll-chips button { 
    white-space: nowrap; 
    flex-shrink: 0; 
    border-radius: 20px; 
    font-weight: 500;
}

/* 保養零件自訂項目 */
.part-item {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    align-items: center;
}
.part-item input { padding: 10px 14px; }
.part-item .part-name { flex: 2; }
.part-item .part-cost { flex: 1; }
.part-item button { flex: 0 0 auto; height: 42px; width: 42px; padding: 0; }

.parts-section {
    background: var(--bg-color);
    padding: 16px;
    border-radius: 14px;
    border: 1.5px dashed var(--border);
    margin-bottom: 20px;
}
.parts-section h3 {
    border-left: none;
    padding-left: 0;
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.total-cost-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--primary-light);
    padding: 16px 20px;
    border-radius: 14px;
    margin: 20px 0;
    color: var(--primary-dark);
    font-weight: 700;
    border: 1px solid rgba(37, 99, 235, 0.1);
}
[data-theme="dark"] .total-cost-bar { 
    color: var(--text-main); 
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.2);
}
.total-cost-bar .cost { font-size: 1.4rem; font-family: 'Inter', sans-serif; }

/* 過濾控制列 */
.filter-bar { 
    display: flex; 
    gap: 10px; 
    margin-bottom: 20px; 
    flex-wrap: wrap; 
}
.filter-bar > * { flex: 1; min-width: 140px; }

.search-input-wrapper {
    position: relative;
    flex: 1.5;
}
.search-input-wrapper input {
    padding-left: 16px;
}

/* 統計專用 Grid */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.analytics-grid.double-column {
    grid-template-columns: repeat(2, 1fr);
}

.analytics-card {
    background: var(--card-bg);
    padding: 16px;
    border-radius: 16px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s;
}

.analytics-card:hover {
    transform: translateY(-2px);
}

.analytics-card.big {
    padding: 24px 16px;
}

.analytics-card.full-width {
    grid-column: span 2;
}

.analytics-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.analytics-card h4 {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.analytics-card p {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary);
    font-family: 'Inter', sans-serif;
}

/* 充電進行中 - 未來科技感控制面板 */
.charging-status-panel {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    padding: 30px 20px;
    border-radius: 20px;
    margin-bottom: 24px;
    border: 1px solid #a7f3d0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .charging-status-panel {
    background: linear-gradient(135deg, #064e3b 0%, #022c22 100%);
    border-color: #047857;
}

.charging-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
}

.charging-badge {
    background: #10b981;
    color: white;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 1px;
}

.charging-status-panel h3 {
    color: #065f46;
    font-size: 1.25rem;
    font-weight: 800;
}
[data-theme="dark"] .charging-status-panel h3 { color: #a7f3d0; }

.charging-timer-wrapper {
    position: relative;
    margin: 24px 0;
    z-index: 1;
}

.charging-timer {
    font-family: 'Inter', 'Courier New', monospace;
    font-size: 3.4rem;
    font-weight: 800;
    color: #047857;
    letter-spacing: 1px;
    text-shadow: 0 4px 10px rgba(16, 185, 129, 0.15);
}
[data-theme="dark"] .charging-timer { color: #34d399; }

#currentChargeInfo {
    background: rgba(255, 255, 255, 0.75);
    padding: 16px;
    border-radius: 14px;
    font-size: 0.92rem;
    color: #065f46;
    text-align: left;
    display: inline-block;
    width: 100%;
    border: 1px solid rgba(16, 185, 129, 0.15);
    box-shadow: var(--shadow-sm);
}
[data-theme="dark"] #currentChargeInfo {
    background: rgba(15, 23, 42, 0.4);
    color: #d1fae5;
    border-color: rgba(52, 211, 153, 0.15);
}

#currentChargeInfo div {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    font-weight: 500;
}
#currentChargeInfo div:last-child { margin-bottom: 0; }

#currentChargeInfo div::before {
    content: "⚡";
    margin-right: 10px;
    font-size: 0.9rem;
}

/* 呼吸燈與脈衝特效 */
.animate-pulse-glow {
    animation: pulseGlow 3s infinite alternate cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes pulseGlow {
    from { box-shadow: 0 0 10px rgba(16, 185, 129, 0.1); }
    to { box-shadow: 0 0 25px rgba(16, 185, 129, 0.35); }
}

/* 置頂橘/黃色備份提示 */
.top-alert {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--warning-light);
    color: #856404;
    padding: 14px 20px;
    text-align: center;
    z-index: 3000;
    box-shadow: var(--shadow-md);
    display: none;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.3s ease;
    border-bottom: 1.5px solid var(--warning);
}
[data-theme="dark"] .top-alert {
    background: var(--warning-light); 
    color: #fff; 
}

.top-alert.unsynced {
    background: var(--warning-light);
    color: #c2410c;
    border-bottom: 2px solid var(--warning);
}

.top-alert.show { display: block; animation: slideDown 0.35s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }

/* 現代 iOS 風格彈出視窗 */
.modal {
    display: none; 
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.modal.active { display: flex; }

.modal-content {
    background: var(--card-bg);
    width: 90%;
    max-width: 520px;
    border-radius: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    color: var(--text-main);
    box-shadow: var(--shadow-premium);
    border: 1px solid var(--border);
}

@keyframes slideUp { 
    from { transform: translateY(40px); opacity: 0; } 
    to { transform: translateY(0); opacity: 1; } 
}

.modal-header { 
    padding: 18px 24px; 
    border-bottom: 1px solid var(--border); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    background: var(--input-bg); 
    flex-shrink: 0;
}
.modal-header h3 { margin: 0; font-size: 1.15rem; font-weight: 700; }

.close-btn {
    font-weight: 600;
    color: var(--primary) !important;
}

.form-scroll-area { 
    padding: 24px; 
    overflow-y: auto; 
    flex: 1;
}

.modal-footer { 
    padding: 16px 24px; 
    border-top: 1px solid var(--border); 
    background: var(--card-bg); 
    flex-shrink: 0;
}

/* 教學內容精緻排版 */
.tutorial-content {
    font-size: 0.92rem;
    line-height: 1.6;
}
.tutorial-content h4 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--primary);
    font-weight: 700;
    font-size: 1rem;
}
.tutorial-content p { margin-bottom: 10px; color: var(--text-main); }
.tutorial-list {
    margin-left: 20px;
    margin-bottom: 12px;
}
.tutorial-list li {
    margin-bottom: 6px;
}
.tutorial-content pre {
    background: var(--input-bg);
    padding: 14px;
    border-radius: 12px;
    overflow-x: auto;
    border: 1.5px solid var(--border);
    font-family: 'Inter', monospace;
    font-size: 0.82rem;
    margin: 12px 0;
    color: var(--text-main);
}
.tutorial-content code {
    color: var(--danger);
    background: var(--danger-light);
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 600;
}
.tutorial-alert {
    color: var(--danger);
    background: var(--danger-light);
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 0.85rem;
    border: 1px solid rgba(239, 68, 68, 0.2);
    margin-top: 12px;
}

/* 歷史卡片 Feed (iOS / Card 風格) */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 24px;
}

.history-card {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 18px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.history-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.card-date { 
    font-weight: 700; 
    color: var(--text-main); 
    font-size: 0.95rem; 
    font-family: 'Inter', sans-serif;
}
.card-time { 
    font-size: 0.8rem; 
    color: var(--text-muted); 
    font-weight: 500; 
    margin-left: 6px; 
}

.card-badge {
    font-size: 0.78rem;
    padding: 5px 12px;
    border-radius: 20px;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
}

.card-body { font-size: 0.92rem; color: var(--text-main); }

.card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.card-row:last-child { margin-bottom: 0; }

.card-label { color: var(--text-muted); font-size: 0.88rem; font-weight: 500; }
.card-val { font-weight: 600; color: var(--text-main); text-align: right; }
.card-val.highlight { color: var(--primary); font-weight: 700; }
.card-val.cost { color: var(--danger); font-weight: 800; }

.card-notes {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--input-bg);
    border-radius: 10px;
    font-size: 0.85rem;
    color: var(--secondary);
    line-height: 1.4;
    border-left: 3px solid var(--secondary);
}

.card-actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-muted);
    background: var(--card-bg);
    border-radius: 18px;
    border: 1.5px dashed var(--border);
    font-weight: 500;
    font-size: 0.95rem;
}

/* Toast 通知優雅美化 */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 28px;
    border-radius: 50px;
    box-shadow: var(--shadow-premium);
    display: none;
    z-index: 2000;
    white-space: nowrap;
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
}
.toast.show { display: block; animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popIn { from { transform: translateX(-50%) scale(0.8); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

/* 亮色模式 Toast */
.toast-success { 
    background: var(--success); 
    color: white; 
    border-color: #059669;
}
.toast-error { 
    background: var(--danger); 
    color: white; 
    border-color: #dc2626;
}

/* 深色模式 Toast */
[data-theme="dark"] .toast-success { 
    background: #059669; 
    color: white; 
    border-color: #10b981;
}
[data-theme="dark"] .toast-error { 
    background: #b91c1c; 
    color: white; 
    border-color: #f87171;
}

/* 備份管理版塊 */
.data-management { 
    margin-top: 36px; 
    padding-top: 24px; 
    border-top: 2px dashed var(--border); 
}
.data-management h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-main);
}
.data-btns-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

/* 最後更新顯示 */
.last-update-info {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 14px;
    text-align: right;
    font-style: italic;
    font-weight: 500;
}

/* 微小滑入動畫 */
.animate-slide-up {
    animation: contentSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes contentSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* RWD 最佳化 */
@media (max-width: 600px) {
    .dashboard { 
        grid-template-columns: repeat(2, 1fr); 
        gap: 8px;
        padding: 12px;
    }
    .stat-card {
        padding: 10px;
        min-height: auto; /* 取消行動端固定的最小高度，由內容自然擴展 */
    }
    .stat-icon {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }
    .stat-card .value {
        font-size: 1.15rem;
    }
    .modal { align-items: flex-end; }
    .modal-content { 
        width: 100%; 
        border-radius: 24px 24px 0 0; 
        max-height: 90vh; 
        animation: mobileSlideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    }
    @keyframes mobileSlideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
}
