:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --text: #111827;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --sidebar-width: 220px;
    --header-height: 60px;
}

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

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

.hidden {
    display: none !important;
}

/* 登录页 */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 360px;
    text-align: center;
}

.login-logo {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 8px;
}

.login-box h2 {
    color: var(--text-secondary);
    font-size: 18px;
    font-weight: normal;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 16px;
}

input[type="text"], input[type="password"], input[type="date"], select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--border);
    color: var(--text);
}

.btn:hover {
    opacity: 0.9;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
}

.btn-block {
    width: 100%;
    padding: 12px;
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.error-msg {
    color: var(--danger);
    font-size: 13px;
    margin-top: 12px;
    min-height: 20px;
}

/* 主布局 */
.main-app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: #1e293b;
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
    font-size: 20px;
    font-weight: bold;
}

.subtitle {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.nav-item.active {
    background: rgba(37, 99, 235, 0.2);
    color: white;
    border-left-color: var(--primary);
}

.nav-icon {
    margin-right: 10px;
    font-size: 16px;
}

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

.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px;
    min-height: 100vh;
}

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

.content-header h1 {
    font-size: 22px;
    font-weight: 600;
}

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

/* 页面 */
.page {
    animation: fadeIn 0.3s ease;
}

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

/* 数据指标卡 */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
}

.metric-label {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.metric-change {
    font-size: 12px;
    color: var(--text-secondary);
}

.metric-change span {
    color: var(--primary);
    font-weight: 600;
}

.metric-change .warning {
    color: var(--warning);
}

/* 图表 */
.chart-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.chart-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
}

.chart-title {
    font-weight: 600;
    margin-bottom: 16px;
    font-size: 15px;
}

.chart-container {
    height: 300px;
    width: 100%;
}

/* 表格 */
.table-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: #f9fafb;
    position: sticky;
    top: 0;
}

.data-table tr:hover {
    background: #f9fafb;
}

.data-table td {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 筛选栏 */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar input,
.filter-bar select {
    width: auto;
    min-width: 160px;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 6px;
    cursor: pointer;
}

.pagination button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 标签 */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.tag-primary {
    background: #dbeafe;
    color: var(--primary);
}

.tag-success {
    background: #d1fae5;
    color: var(--success);
}

.tag-warning {
    background: #fef3c7;
    color: var(--warning);
}

.tag-danger {
    background: #fee2e2;
    color: var(--danger);
}

/* 内容标签页 */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.tab-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    color: var(--text-secondary);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
}

/* 导出 */
.export-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.export-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    text-align: center;
}

.export-card h3 {
    font-size: 16px;
    margin-bottom: 8px;
}

.export-card p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 16px;
}

.date-range {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    justify-content: center;
}

.date-range input {
    width: 130px;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1001;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: 60vh;
}

.detail-section {
    margin-bottom: 20px;
}

.detail-section h4 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-section p, .detail-section .detail-value {
    font-size: 14px;
    line-height: 1.6;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.detail-item {
    background: #f9fafb;
    padding: 12px;
    border-radius: 8px;
}

.detail-item label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.detail-item span {
    font-weight: 600;
}

/* 地图占位 */
.map-placeholder {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

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

.page-back {
    margin-bottom: 16px;
}

/* 响应式 */
@media (max-width: 1200px) {
    .chart-row {
        grid-template-columns: 1fr;
    }
    .export-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
        height: auto;
    }
    .content {
        margin-left: 0;
    }
    .main-app {
        flex-direction: column;
    }
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    .export-grid {
        grid-template-columns: 1fr;
    }
}

/* 操作链接 */
.action-link {
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
    margin-right: 8px;
}

.action-link:hover {
    text-decoration: underline;
}

.action-link.danger {
    color: var(--danger);
}

/* 状态文字 */
.status-pending { color: var(--warning); }
.status-completed { color: var(--success); }
.status-closed { color: var(--text-secondary); }
.status-paid { color: var(--info); }

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}
