:root {
  --primary: #1677ff;
  --success: #52c41a;
  --error: #ff4d4f;
  --warning: #faad14;
  --text: #333;
  --text-secondary: #666;
  --border: #e8e8e8;
  --bg: #f5f5f5;
  --card: #fff;
  --sidebar: 240px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* 登录页 */
.login-page {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #001529 0%, #003a70 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.login-box {
  background: var(--card);
  border-radius: 16px;
  padding: 48px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
  max-width: 420px;
  width: 90%;
}

.login-box h1 { color: #001529; font-size: 24px; margin: 16px 0 8px; }
.login-box .subtitle { color: var(--text-secondary); font-size: 14px; margin-bottom: 32px; }

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #4096ff; }

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.btn-full {
  width: 100%;
  justify-content: center;
  padding: 14px;
  font-size: 16px;
  margin-bottom: 12px;
}

.hint { color: #999; font-size: 12px; margin-top: 12px; }

.error-box {
  background: #fff2f0;
  border: 1px solid #ffccc7;
  color: var(--error);
  padding: 12px;
  border-radius: 8px;
  margin-top: 16px;
  display: none;
  font-size: 14px;
}

.features {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid #f0f0f0;
}

.feature { text-align: center; color: #666; font-size: 12px; }
.feature-icon { font-size: 24px; margin-bottom: 8px; }

/* 主应用 */
.app-container { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: var(--sidebar);
  background: linear-gradient(180deg, #001529 0%, #002140 100%);
  color: #fff;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.logo { padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.logo h2 { font-size: 18px; font-weight: 600; }

.nav-menu { padding: 12px 0; }

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-item:hover { color: #fff; background: rgba(255,255,255,0.1); }
.nav-item.active { color: #fff; background: var(--primary); }
.nav-item .icon { margin-right: 12px; font-size: 16px; }

.user-panel {
  position: absolute;
  bottom: 20px;
  left: 20px;
  right: 20px;
  color: rgba(255,255,255,0.65);
  font-size: 12px;
}

.user-panel a { color: rgba(255,255,255,0.65); text-decoration: none; }
.user-panel a:hover { color: #fff; }

/* 主内容 */
.main-content { flex: 1; margin-left: var(--sidebar); min-height: 100vh; }

.top-bar {
  background: var(--card);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar h1 { font-size: 20px; font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 16px; }

.content-area { padding: 24px; }

/* 页面 */
.page { display: none; }
.page.active { display: block; }

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

.page-header h3 { font-size: 18px; font-weight: 600; }

/* 统计卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.stat-icon { font-size: 32px; margin-right: 16px; }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 24px; font-weight: 600; }
.stat-label { font-size: 14px; color: var(--text-secondary); }

/* 卡片 */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 20px;
}

.card h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

/* 表格 */
.table-container {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.data-table { width: 100%; border-collapse: collapse; }
.data-table thead { background: var(--bg); }
.data-table th, .data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th { font-weight: 600; color: var(--text-secondary); }
.data-table tbody tr:hover { background: rgba(22,119,255,0.04); }

.action-link { color: var(--primary); margin-right: 12px; cursor: pointer; text-decoration: none; }
.action-link:hover { text-decoration: underline; }
.action-link.delete { color: var(--error); }

.empty-text { color: #999; text-align: center; padding: 40px; }

/* 表单 */
.input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  width: 100%;
}

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

select.input { cursor: pointer; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; }

/* 月份选择器 */
.month-selector { display: flex; gap: 12px; align-items: center; }

/* 模态框 */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.active { display: flex; }

.modal-content {
  background: var(--card);
  border-radius: 12px;
  width: 480px;
  max-width: 90%;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

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

.modal-header h3 { font-size: 18px; font-weight: 600; }

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

.modal-body { padding: 20px; }

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
  z-index: 2000;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--error); }

/* 状态标签 */
.status-tag {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.status-tag.pending { background: #fff7e6; color: var(--warning); }
.status-tag.calculated { background: #e6f7ff; color: var(--primary); }
.status-tag.approved { background: #f6ffed; color: var(--success); }
.status-tag.paid { background: #d9f7be; color: var(--success); }
.status-tag.unpaid { background: #fff1f0; color: var(--error); }
.status-tag.declared { background: #e6f7ff; color: var(--primary); }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .logo h2, .nav-item span:last-child { display: none; }
  .main-content { margin-left: 60px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .modal-content { width: 95%; }
}

/* 滚动条 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }
