:root {
    --primary-color: #10B981; /* Emerald Green */
    --bg-color: #F2F2F7;
    --card-bg: #FFFFFF;
    --text-color: #1C1C1E;
    --secondary-text: #8E8E93;
    --border-radius: 16px;
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    --accent-color: #10B981;
    --danger-color: #FF3B30;
    --success-color: #34C759;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none; /* Disable text selection */
    -webkit-user-select: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding: 16px;
    padding-bottom: calc(70px + env(safe-area-inset-bottom)); /* 适配新的导航栏高度和安全区 */
    font-size: 14px; /* 全局减小字体 */
    touch-action: manipulation; /* 禁用双击放大，允许正常点击和滚动 */
}

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

/* Tab Management */
.tab-content {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.tab-content.active {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

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

/* Card Styling */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(0,0,0,0.03);
}

/* Summary Grid */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 8px;
}

.summary-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 14px !important;
}

.summary-card .label {
    font-size: 11px;
    color: var(--secondary-text);
    margin-bottom: 2px;
    font-weight: 500;
}

.summary-card .value {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

#totalAmount {
    color: var(--primary-color);
}

/* History List Styling */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px solid #E5E5EA;
    margin-bottom: 4px;
    font-size: 12px;
    color: var(--secondary-text);
    font-weight: 500;
}

.history-header .header-date {
    text-align: left;
}

.history-header .header-amount {
    flex: 1;
    text-align: right;
    margin-right: 12px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #F2F2F7;
    align-items: center;
    transition: background-color 0.2s;
}

.history-item:active {
    background-color: #F9F9F9;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item .date {
    color: var(--secondary-text);
    font-size: 13px;
}

.history-item .amount {
    font-weight: 600;
    flex: 1;
    text-align: right;
    margin-right: 12px;
    font-size: 14px;
}

.delete-btn {
    background: #FFF5F5;
    color: var(--danger-color);
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.delete-btn:active {
    background: var(--danger-color);
    color: #fff;
}

/* Bottom Nav Styling */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 55px; /* 减小高度 */
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -1px 0 rgba(0,0,0,0.05);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom); /* 适配全面屏底部安全区，取代固定的 padding */
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--secondary-text);
    font-size: 11px;
    cursor: pointer;
    flex: 1;
    transition: all 0.3s;
    gap: 4px;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-icon svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* FAB Styling */
.fab {
    position: fixed;
    right: 24px;
    bottom: calc(75px + env(safe-area-inset-bottom)); /* 适配新的导航栏高度和安全区 */
    width: 56px;
    height: 56px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 28px;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.3);
    cursor: pointer;
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.fab:active {
    transform: scale(0.9);
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    justify-content: center;
    align-items: flex-end;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    width: 100%;
    max-width: 500px;
    border-radius: 24px 24px 0 0;
    padding: 24px;
    animation: slideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
}

.close {
    width: 32px;
    height: 32px;
    background: #F2F2F7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--secondary-text);
}

/* Form Styling in Modal */
.form-group {
    margin-bottom: 20px;
}

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

input[type="date"], input[type="number"], input[type="text"], input[type="password"] {
    width: 100%;
    padding: 16px;
    border: 1px solid #E5E5EA;
    border-radius: 12px;
    font-size: 17px;
    background: #F9F9F9;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

input[type="date"], input[type="number"] {
    text-align: center; /* Center align for specific inputs */
}

/* Hide number input arrows */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield; /* Firefox */
}

input[type="date"]:focus, input[type="number"]:focus, input[type="text"]:focus, input[type="password"]:focus {
    border-color: var(--primary-color);
    background: #fff;
}

.date-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 24px;
}

.date-buttons button {
    padding: 12px;
    background: #F2F2F7;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
}

/* Click state for date buttons */
.date-buttons button:active {
    background: var(--primary-color);
    color: #fff;
}

.primary-btn {
    width: 100%;
    padding: 18px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

/* Table Styling */
.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.data-table th {
    font-size: 13px;
    color: var(--secondary-text);
    font-weight: 500;
    padding: 12px 8px;
    text-align: left;
}

.data-table td {
    padding: 16px 8px;
    font-size: 15px;
    border-bottom: 1px solid #F2F2F7;
}

.data-table th:nth-child(2),
.data-table th:nth-child(3),
.data-table td:nth-child(2),
.data-table td:nth-child(3) {
    text-align: right;
}

.no-data-row td {
    text-align: center !important;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.refresh-btn {
    background: #F2F2F7;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* Auth Container */
.auth-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 80vh;
}
.auth-title {
    text-align: center;
    font-size: 28px;
    margin-bottom: 30px;
    font-weight: 700;
    color: var(--primary-color);
}

.captcha-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.captcha-container input {
    flex: 1;
}

.captcha-container img {
    height: 48px;
    border-radius: 8px;
    border: 1px solid #E5E5EA;
}

.text-center { text-align: center; }
.mt-3 { margin-top: 15px; }
.btn-link { background: none; border: none; color: var(--primary-color); font-size: 14px; cursor: pointer; }

/* Profile View */
.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 30px 20px;
}
.avatar {
    width: 60px;
    height: 60px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
}
.profile-info h2 { font-size: 22px; margin-bottom: 5px; }
.settings-card {
    margin-top: 12px;
}
.settings-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}
.view-mode-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.view-mode-btn {
    border: 1px solid #E5E5EA;
    background: #F9F9F9;
    color: var(--secondary-text);
    border-radius: 10px;
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}
.view-mode-btn.active {
    background: rgba(16, 185, 129, 0.12);
    color: var(--primary-color);
    border-color: rgba(16, 185, 129, 0.3);
}
.logout-btn {
    background: var(--danger-color);
    margin-top: 30px;
}

.hidden-view {
    display: none;
}

html[data-stats-view-mode="calendar"] #statsListView {
    display: none;
}

html[data-stats-view-mode="calendar"] #statsCalendarView {
    display: block;
}

html[data-stats-view-mode="list"] #statsListView {
    display: block;
}

html[data-stats-view-mode="list"] #statsCalendarView {
    display: none;
}

.stats-calendar-view {
    padding: 12px;
}

.stats-empty-text {
    text-align: center;
    color: var(--secondary-text);
    font-size: 14px;
    padding: 20px 0;
}

.calendar-month-card {
    border: 1px solid #F0F0F0;
    border-radius: 12px;
    padding: 10px;
}

.calendar-month-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.month-grid-amount {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.3;
}

.month-grid-count {
    font-size: 12px;
    color: var(--secondary-text);
    margin-top: 2px;
}

.calendar-month-card {
    border-color: rgba(16, 185, 129, 0.25);
    background: rgba(16, 185, 129, 0.08);
}

.taobao-header-card {
    margin-bottom: 10px;
}

.taobao-cookie-input {
    width: 100%;
    min-height: 88px;
    resize: vertical;
    border: 1px solid #E5E5EA;
    border-radius: 12px;
    padding: 10px;
    font-size: 13px;
    font-family: inherit;
    margin-bottom: 10px;
    outline: none;
}

.taobao-cookie-input:focus {
    border-color: var(--primary-color);
}

.taobao-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.taobao-btn {
    padding: 12px;
    font-size: 14px;
}

.taobao-fetch-btn {
    background: #2563EB;
}

.taobao-fetch-btn.loading {
    opacity: 0.85;
}

.taobao-stats-grid {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    margin: 12px 0 6px 0;
}

.stat-box {
    border-radius: 6px;
    padding: 4px 2px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    color: #fff;
    min-height: 40px;
}

/* 4种不同的渐变色深色背景 */
.stat-today-orders {
    background: linear-gradient(135deg, #5AB1FF 0%, #2D82F5 100%);
}

.stat-today-fee {
    background: linear-gradient(135deg, #FF8D98 0%, #FFB664 100%);
}

.stat-total-orders {
    background: linear-gradient(135deg, #1CD3A2 0%, #0EB589 100%);
}

.stat-total-fee {
    background: linear-gradient(135deg, #A27BF4 0%, #7E51F4 100%);
}

.stat-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0;
    text-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

.stat-value {
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    margin-bottom: 2px;
}

.stat-box.highlight .stat-value {
    color: var(--primary-color);
}

.taobao-page-stats {
    text-align: center;
    font-size: 12px;
    color: #9CA3AF;
    margin-bottom: 12px;
}

.taobao-list-card {
    padding: 10px;
}

.taobao-empty {
    text-align: center;
    color: var(--secondary-text);
    font-size: 14px;
    padding: 16px 0;
}

.taobao-loading {
    text-align: center;
    color: var(--secondary-text);
    font-size: 14px;
    padding: 18px 0;
}

.taobao-item {
    border: 1px solid #EEF0F4;
    border-radius: 12px;
    padding: 10px;
    background: #fff;
}

.taobao-item + .taobao-item {
    margin-top: 8px;
}

.taobao-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
}

.taobao-item-main {
    display: flex;
    gap: 10px;
}

.taobao-item-image {
    width: 44px;
    min-width: 44px;
    height: 44px;
}

.taobao-item-content {
    flex: 1;
    min-width: 0;
}

.taobao-item-title {
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 4px;
    word-break: break-word;
}

.taobao-item-meta {
    font-size: 12px;
    color: var(--secondary-text);
    line-height: 1.4;
    word-break: break-all;
}

.taobao-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #E5E5EA;
}

/* Modal footer */
.modal-footer {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}
.btn-danger { background: var(--danger-color); }

/* Toast Notification */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success { background: rgba(52, 199, 89, 0.9); }
.toast.error { background: rgba(255, 59, 48, 0.9); }

@media (max-width: 480px) {
    body { padding: 16px; padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
}
