:root {
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-dark: #4338ca;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #4f46e5;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow: 0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-sm: 6px;
    --sidebar-width: 220px;
}

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

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

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
    width: 36px; height: 36px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.logo-text { color: #fff; font-weight: 600; font-size: 15px; }

.nav-menu { flex: 1; padding: 12px 8px; overflow-y: auto; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    transition: all 0.2s;
}

.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-icon { font-size: 16px; }

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.logout-btn {
    display: block;
    padding: 10px 12px;
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    text-align: center;
    transition: all 0.2s;
}
.logout-btn:hover { background: rgba(239,68,68,0.2); color: #fca5a5; }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    flex-direction: column;
    gap: 4px;
}
.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
}

.page-title { font-size: 18px; font-weight: 600; }
.topbar-user { margin-left: auto; color: var(--text-secondary); font-size: 13px; }

.content-wrapper {
    padding: 20px;
    flex: 1;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
}

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

.card-title { font-size: 16px; font-weight: 600; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
}
.btn:hover { background: var(--primary-dark); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #059669; }
.btn-warning { background: var(--warning); }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: var(--text-secondary); }
.btn-secondary:hover { background: #475569; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); border-color: var(--text-secondary); }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}
th {
    background: var(--border-light);
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}
tr:hover td { background: #f8fafc; }

.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text);
}
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color 0.2s;
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { background: #fff; }

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.priority-high { background: #fee2e2; color: #dc2626; }
.priority-medium { background: #fef3c7; color: #d97706; }
.priority-low { background: #dbeafe; color: #2563eb; }

.status-done { background: #d1fae5; color: #059669; }
.status-in_progress { background: #dbeafe; color: #2563eb; }
.status-todo { background: #e2e8f0; color: #475569; }

.tag {
    display: inline-block;
    padding: 2px 8px;
    background: #eef2ff;
    color: var(--primary);
    border-radius: 4px;
    font-size: 12px;
    margin-right: 4px;
    margin-bottom: 2px;
}

.progress-bar {
    background: var(--border-light);
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 10px;
    transition: width 0.3s ease;
}
.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger { background: var(--danger); }

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.dashboard-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.dashboard-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.dashboard-card h3 {
    font-size: 15px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-card { text-align: center; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); margin: 8px 0; }
.stat-label { color: var(--text-secondary); font-size: 13px; }
.stat-change { font-size: 13px; margin-top: 4px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

.task-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}
.task-item:last-child { border-bottom: none; }
.task-checkbox { cursor: pointer; width: 16px; height: 16px; }
.task-title { flex: 1; }
.task-title.done { text-decoration: line-through; color: var(--text-light); }

.plan-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}
.plan-item:last-child { border-bottom: none; }
.plan-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.plan-name { font-weight: 500; }
.plan-progress-text { font-size: 12px; color: var(--text-secondary); }

.note-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}
.note-item:last-child { border-bottom: none; }
.note-item-title { font-weight: 500; margin-bottom: 2px; }
.note-item-meta { font-size: 12px; color: var(--text-secondary); }

.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    align-items: flex-end;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 140px; }

.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}
.page-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
}
.page-btn:hover { background: var(--bg); }
.page-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}
.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 36px 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
.login-card h1 {
    text-align: center;
    margin-bottom: 8px;
    color: var(--text);
}
.login-card .subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 14px;
}
.login-card .btn { width: 100%; padding: 12px; font-size: 15px; }

.overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
}
.overlay.active { display: block; }

.gantt-bar {
    position: relative;
    height: 24px;
    background: var(--border-light);
    border-radius: 12px;
    overflow: hidden;
}
.gantt-fill {
    position: absolute;
    height: 100%;
    background: var(--primary);
    border-radius: 12px;
    min-width: 4px;
}

.chart-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.note-content {
    line-height: 1.8;
    font-size: 15px;
}
.note-content h1, .note-content h2, .note-content h3 { margin: 16px 0 8px; }
.note-content p { margin-bottom: 12px; }
.note-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 12px 0;
}
.note-content code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
}
.note-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}
.note-content blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 16px;
    color: var(--text-secondary);
    margin: 12px 0;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background: var(--border-light);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.editor-toolbar button {
    padding: 4px 10px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.editor-toolbar button:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.editor-content {
    min-height: 300px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    background: #fff;
    outline: none;
    line-height: 1.6;
}
.editor-content:focus { border-color: var(--primary); }

.trade-buy { color: var(--success); }
.trade-sell { color: var(--danger); }
.trade-dividend { color: var(--warning); }
.trade-drip { color: var(--info); }

.asset-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.asset-summary-item {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    text-align: center;
}
.asset-summary-item .label { color: var(--text-secondary); font-size: 13px; margin-bottom: 6px; }
.asset-summary-item .value { font-size: 22px; font-weight: 700; }
.asset-summary-item .value.positive { color: var(--success); }
.asset-summary-item .value.negative { color: var(--danger); }
.asset-summary-item.highlight { border: 2px solid var(--primary); }

.section-divider {
    margin: 20px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text);
}

.form-hint {
    color: var(--text-secondary);
    font-size: 13px;
    margin: -4px 0 16px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    color: var(--text-secondary);
    font-size: 13px;
}

.detail-notes {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.repay-info-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.repay-info-bar .negative { color: var(--danger); }

.tag-warning { background: #fef3c720; color: var(--warning); }
.tag-success { background: #d1fae520; color: var(--success); }

.stat-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.positive { color: var(--success); }
.negative { color: var(--danger); }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.active { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: flex; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .content-wrapper { padding: 12px; }
    .topbar { padding: 10px 12px; }
    .page-title { font-size: 16px; }
    .card { padding: 16px; }
    .form-row { flex-direction: column; gap: 0; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar .form-group { width: 100%; }
    .btn { padding: 10px 16px; font-size: 14px; }
    .btn-sm { padding: 6px 12px; font-size: 13px; }
    .asset-summary { grid-template-columns: repeat(2, 1fr); }
    th, td { padding: 8px 10px; font-size: 13px; }
}

@media (max-width: 480px) {
    .stat-value { font-size: 22px; }
    .asset-summary { grid-template-columns: 1fr; }
    .login-card { padding: 24px 20px; }
}
