/* ==========================================
   AI智能记账系统 - 现代化UI样式
   ========================================== */

/* ========== CSS Variables ========== */
:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --primary-light: #818cf8;
    --secondary: #0ea5e9;
    --accent: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.15);
    --transition: all 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ========== Login Page ========== */
#loginPage {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 30%, #4f46e5 70%, #0ea5e9 100%);
    position: relative;
    overflow: hidden;
}
#loginPage::before {
    content: "";
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(129,140,248,0.15) 0%, transparent 70%);
    top: -200px;
    right: -200px;
    border-radius: 50%;
}
#loginPage::after {
    content: "";
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(14,165,233,0.12) 0%, transparent 70%);
    bottom: -150px;
    left: -150px;
    border-radius: 50%;
}
.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 20px;
}
.login-card {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 36px 32px;
    box-shadow: var(--shadow-xl);
    animation: cardFloat 0.6s ease-out;
}
@keyframes cardFloat {
    from { opacity: 0; transform: translateY(30px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.login-header { text-align: center; margin-bottom: 24px; }
.login-icon {
    width: 72px; height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px; color: white;
    box-shadow: 0 8px 24px rgba(79,70,229,0.3);
}
.login-header h1 { font-size: 24px; font-weight: 700; color: var(--text); margin-bottom: 4px; letter-spacing: -0.5px; }
.login-header p { color: var(--text-secondary); font-size: 14px; }
.login-tabs {
    display: flex; gap: 4px;
    margin-bottom: 24px;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 4px;
}
.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow);
    font-weight: 600;
}
.tab-btn:hover:not(.active) { color: var(--text); }

.login-form { display: none; }
.login-form.active { display: block; }

.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.form-group label i { margin-right: 4px; color: var(--primary-light); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    background: #f8fafc;
    outline: none;
    font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
    background: white;
}
.form-group textarea { resize: vertical; min-height: 80px; }

.btn-primary {
    padding: 11px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(79,70,229,0.35); }
.btn-primary:active { transform: translateY(0); }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }

.btn-secondary {
    padding: 11px 20px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    background: white;
    color: var(--text);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger {
    padding: 11px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    background: var(--danger);
    color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; }

.form-tip { text-align: center; font-size: 12px; color: var(--text-light); margin-top: 12px; }

/* ========== App Layout ========== */
#appPage { display: none; min-height: 100vh; }
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: var(--transition);
}
.sidebar-logo {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-logo .logo-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; color: white;
    flex-shrink: 0;
}
.sidebar-logo h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.3px; line-height: 1.2; }
.sidebar-logo span { font-size: 11px; color: var(--text-light); opacity: 0.6; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: rgba(255,255,255,0.65);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    margin-bottom: 2px;
}
.menu-item:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}
.menu-item.active {
    background: rgba(79,70,229,0.4);
    color: white;
    font-weight: 600;
}
.menu-item i { width: 18px; text-align: center; font-size: 14px; }

.sidebar-footer {
    padding: 14px 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}
.sidebar-user:hover { background: rgba(255,255,255,0.08); }
.user-avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: white;
    font-weight: 600;
    flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: white; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.5); }

/* Main Content */
.main-area {
    flex: 1;
    margin-left: 240px;
    padding: 24px;
    min-height: 100vh;
}
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.main-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.main-header .subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }
.main-content { max-width: 1200px; }
.page { display: none; }
.page.active { display: block; animation: pageIn 0.3s ease-out; }
@keyframes pageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== Cards ========== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    border: 1px solid var(--border);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* Stat cards */
.stat-card {
    padding: 20px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.stat-icon.blue { background: #e0f2fe; color: #0284c7; }
.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.yellow { background: #fef3c7; color: #d97706; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-info { flex: 1; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ========== Tables ========== */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table th {
    background: #f8fafc;
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
}
table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table tr:hover td { background: #f8fafc; }
table tr:last-child td { border-bottom: none; }

/* ========== Badges ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-default { background: #f1f5f9; color: #475569; }

/* ========== Loading ========== */
.loading {
    display: flex; align-items: center; justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
}
.loading::after {
    content: "";
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Toast ========== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease-out;
    max-width: 360px;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
.toast-success { background: var(--accent); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }
.toast-warning { background: var(--warning); }

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
    background: white;
    border-radius: 16px;
    padding: 28px;
    width: 90%;
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlide 0.3s ease-out;
}
@keyframes modalSlide {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close {
    width: 32px; height: 32px;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    transition: var(--transition);
}
.modal-close:hover { background: #e2e8f0; }

/* ========== Empty State ========== */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-secondary); }
.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }

/* ========== Guidance System ========== */
#gb:hover { transform: scale(1.1); }
#gb:active { transform: scale(0.95); }
#gp { animation: gpSlideIn 0.25s ease-out; }
@keyframes gpSlideIn {
    from { opacity: 0; transform: translateY(10px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
#gpBody { scrollbar-width: thin; }
#gpBody::-webkit-scrollbar { width: 4px; }
#gpBody::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }
#gwiz { animation: gwizFadeIn 0.3s ease-out; }
@keyframes gwizFadeIn { from { opacity: 0; } to { opacity: 1; } }
#gwiz > div { animation: gwizScaleIn 0.35s ease-out; }
@keyframes gwizScaleIn { from { opacity: 0; transform: scale(0.9) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }
#gpBody div[onclick]:hover { background: #f3f4f6; }

/* ========== Utilities ========== */
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Reports specific */
.report-section { margin-bottom: 32px; }
.report-section h3 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.report-row { display: flex; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.report-row.total { font-weight: 700; border-top: 2px solid var(--text); border-bottom: 2px solid var(--text); margin-top: 8px; }
.report-label { flex: 1; color: var(--text-secondary); }
.report-value { font-weight: 600; text-align: right; min-width: 120px; }
.report-value.income { color: var(--accent); }
.report-value.expense { color: var(--danger); }

/* AI batch input */
.ai-batch-input { width: 100%; min-height: 120px; font-family: monospace; font-size: 13px; line-height: 1.6; }

/* Invoice preview */
.invoice-preview { max-width: 200px; max-height: 200px; border-radius: var(--radius-sm); object-fit: cover; cursor: pointer; }

/* Charts */
.chart-container { position: relative; height: 250px; margin: 16px 0; }