/* ============================================
   邹城市村情事务信息化平台 - 设计系统
   Design Tokens + Components
   ============================================ */

/* --- Design Tokens --- */
:root {
  /* 主色调 - 政务深蓝 */
  --c-primary: #1a4a8a;
  --c-primary-light: #2d6bdd;
  --c-primary-dark: #0f2d5c;
  --c-primary-bg: #e8f0fc;
  --c-primary-hover: #1958a8;

  /* 功能色 */
  --c-success: #16a34a;
  --c-success-bg: #dcfce7;
  --c-warning: #d97706;
  --c-warning-bg: #fef3c7;
  --c-danger: #dc2626;
  --c-danger-bg: #fee2e2;
  --c-info: #0891b2;
  --c-info-bg: #cffafe;

  /* 中性色 */
  --c-text-1: #1f2937;
  --c-text-2: #4b5563;
  --c-text-3: #6b7280;
  --c-text-4: #9ca3af;
  --c-border: #e5e7eb;
  --c-border-light: #f0f1f3;
  --c-bg-page: #f0f2f5;
  --c-bg-card: #ffffff;
  --c-bg-hover: #f7f9fc;

  /* 侧边栏 */
  --c-sidebar-bg: #0c2340;
  --c-sidebar-text: #a3b3cc;
  --c-sidebar-text-active: #ffffff;
  --c-sidebar-item-hover: rgba(255,255,255,0.08);
  --c-sidebar-item-active: linear-gradient(90deg, var(--c-primary-light), var(--c-primary));

  /* 字号 */
  --fz-xs: 12px;
  --fz-sm: 13px;
  --fz-base: 14px;
  --fz-md: 15px;
  --fz-lg: 16px;
  --fz-xl: 18px;
  --fz-2xl: 20px;
  --fz-3xl: 24px;
  --fz-4xl: 28px;

  /* 圆角 */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-xl: 12px;
  --r-full: 9999px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-xl: 0 8px 32px rgba(0,0,0,0.12);

  /* 间距 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* 布局 */
  --sidebar-w: 220px;
  --sidebar-collapsed-w: 64px;
  --topbar-h: 56px;
  --transition: 0.2s ease;
}

/* --- Reset --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--c-bg-page);
  color: var(--c-text-1);
  font-size: var(--fz-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-hover); }
ul, ol { list-style: none; }
img { max-width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* --- App Shell Layout --- */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--c-sidebar-bg);
  color: var(--c-sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: width var(--transition);
}
.sidebar-logo {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.sidebar-logo .logo-icon {
  width: 32px; height: 32px;
  background: var(--c-primary-light);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff; font-weight: 700;
  flex-shrink: 0;
}
.sidebar-logo .logo-text {
  font-size: var(--fz-sm);
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-nav { flex: 1; padding: 8px 0; }
.sidebar-group-label {
  font-size: 11px;
  color: var(--c-text-4);
  padding: 12px 20px 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--c-sidebar-text);
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  white-space: nowrap;
  position: relative;
}
.sidebar-item:hover {
  background: var(--c-sidebar-item-hover);
  color: var(--c-sidebar-text-active);
}
.sidebar-item.active {
  background: var(--c-sidebar-item-active);
  color: var(--c-sidebar-text-active);
  border-left-color: var(--c-primary-light);
}
.sidebar-item .nav-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-item .nav-icon svg { width: 18px; height: 18px; }
.sidebar-sub {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.sidebar-sub.open { max-height: 300px; }
.sidebar-sub .sidebar-item { padding-left: 48px; font-size: var(--fz-sm); }
.sidebar-item .submenu-toggle {
  margin-left: auto;
  display: flex;
  align-items: center;
  opacity: .55;
  padding: 2px;
  border-radius: 4px;
  flex-shrink: 0;
}
.sidebar-item .submenu-toggle:hover { opacity: 1; }
.sidebar-item .submenu-toggle svg { width: 14px; height: 14px; }

/* Main Content Area */
.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fz-sm);
  color: var(--c-text-3);
}
.breadcrumb a { color: var(--c-text-3); }
.breadcrumb .sep { color: var(--c-text-4); }
.breadcrumb .current { color: var(--c-text-1); font-weight: 500; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-btn {
  width: 32px; height: 32px;
  border: none; background: none; cursor: pointer;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--c-text-3);
  position: relative;
  transition: background var(--transition);
}
.topbar-btn:hover { background: var(--c-bg-hover); }
.topbar-btn .badge {
  position: absolute; top: 4px; right: 4px;
  width: 8px; height: 8px;
  background: var(--c-danger);
  border-radius: 50%;
}
.user-chip {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-md);
  transition: background var(--transition);
}
.user-chip:hover { background: var(--c-bg-hover); }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--c-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fz-sm); font-weight: 600;
}
.user-name { font-size: var(--fz-sm); color: var(--c-text-1); }
.user-role { font-size: var(--fz-xs); color: var(--c-text-3); }

/* Content */
.content-area { flex: 1; padding: 16px 20px; overflow-x: hidden; }

/* --- Cards --- */
.card {
  background: var(--c-bg-card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--c-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: var(--fz-md); font-weight: 600; color: var(--c-text-1); }
.card-body { padding: 16px; }

/* --- Stats Cards --- */
.stats-grid { display: grid; gap: 16px; margin-bottom: 16px; }
.stat-card {
  background: #fff;
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.stat-info { flex: 1; min-width: 0; }
.stat-label { font-size: var(--fz-sm); color: var(--c-text-3); margin-bottom: 4px; }
.stat-value { font-size: var(--fz-3xl); font-weight: 700; color: var(--c-text-1); line-height: 1.2; }
.stat-trend { font-size: var(--fz-xs); display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.stat-trend.up { color: var(--c-success); }
.stat-trend.down { color: var(--c-danger); }
.stat-trend.flat { color: var(--c-text-3); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: #fff;
  color: var(--c-text-1);
  font-size: var(--fz-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { border-color: var(--c-primary-light); color: var(--c-primary); }
.btn-primary {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--c-primary-hover); border-color: var(--c-primary-hover); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: var(--fz-xs); }
.btn-lg { padding: 10px 24px; font-size: var(--fz-md); }
.btn-text { border: none; background: none; padding: 4px 8px; color: var(--c-primary); }
.btn-text:hover { background: var(--c-primary-bg); }
.btn-danger { color: var(--c-danger); border-color: var(--c-border); }
.btn-danger:hover { background: var(--c-danger-bg); border-color: var(--c-danger); }

/* --- Tables --- */
table.data-table { width: 100%; border-collapse: collapse; font-size: var(--fz-sm); }
.data-table th {
  text-align: left;
  padding: 10px 12px;
  background: #fafbfc;
  color: var(--c-text-3);
  font-weight: 600;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-border-light);
  color: var(--c-text-1);
}
.data-table tbody tr:hover { background: var(--c-bg-hover); }
.data-table .actions { display: flex; gap: 4px; }

/* --- Tags / Badges --- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: var(--fz-xs);
  line-height: 1.6;
}
.tag-primary { background: var(--c-primary-bg); color: var(--c-primary); }
.tag-success { background: var(--c-success-bg); color: var(--c-success); }
.tag-warning { background: var(--c-warning-bg); color: var(--c-warning); }
.tag-danger { background: var(--c-danger-bg); color: var(--c-danger); }
.tag-info { background: var(--c-info-bg); color: var(--c-info); }
.tag-default { background: #f3f4f6; color: var(--c-text-2); }

/* --- Form --- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: var(--fz-sm); color: var(--c-text-2); margin-bottom: 6px; font-weight: 500; }
.form-label .required { color: var(--c-danger); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-size: var(--fz-sm);
  background: #fff;
  color: var(--c-text-1);
  transition: border-color var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--c-primary-light);
  box-shadow: 0 0 0 3px rgba(45,107,221,0.1);
}
.form-textarea { resize: vertical; min-height: 80px; }

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar .form-input, .filter-bar .form-select { width: auto; min-width: 140px; }

/* --- Pagination --- */
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 12px; }
.pagination .page-btn {
  min-width: 32px; height: 32px;
  border: 1px solid var(--c-border);
  background: #fff;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: var(--fz-sm);
  color: var(--c-text-2);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.pagination .page-btn:hover { border-color: var(--c-primary-light); color: var(--c-primary); }
.pagination .page-btn.active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.pagination .page-info { font-size: var(--fz-xs); color: var(--c-text-3); margin-right: 8px; }

/* --- Modal --- */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--r-xl);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
}
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--c-border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: var(--fz-lg); font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--c-border); display: flex; justify-content: flex-end; gap: 8px; }

/* --- Drawer (slide panel) --- */
.drawer-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 199; }
.drawer-overlay.open { display: block; }
.drawer {
  position: fixed; top: 0; right: -680px;
  width: 640px; max-width: 90vw; height: 100vh;
  background: #fff;
  z-index: 200;
  box-shadow: -4px 0 24px rgba(0,0,0,0.1);
  transition: right 0.25s ease;
  display: flex; flex-direction: column;
}
.drawer.open { right: 0; }
.drawer-header { padding: 16px 20px; border-bottom: 1px solid var(--c-border); display: flex; align-items: center; justify-content: space-between; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer-footer { padding: 12px 20px; border-top: 1px solid var(--c-border); display: flex; justify-content: flex-end; gap: 8px; }

/* --- Tabs --- */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--c-border); margin-bottom: 16px; }
.tab-item {
  padding: 8px 16px;
  font-size: var(--fz-sm);
  color: var(--c-text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}
.tab-item:hover { color: var(--c-primary); }
.tab-item.active { color: var(--c-primary); border-bottom-color: var(--c-primary); font-weight: 500; }

/* --- Progress --- */
.progress { height: 6px; background: #e5e7eb; border-radius: var(--r-full); overflow: hidden; }
.progress-bar { height: 100%; background: var(--c-primary); border-radius: var(--r-full); transition: width 0.3s; }

/* --- Timeline --- */
.timeline { padding-left: 20px; position: relative; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--c-border); }
.timeline-item { position: relative; padding-bottom: 20px; padding-left: 20px; }
.timeline-item::before { content: ''; position: absolute; left: -14px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--c-primary); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--c-primary); }
.timeline-item.done::before { background: var(--c-success); box-shadow: 0 0 0 2px var(--c-success); }
.timeline-item.current::before { background: var(--c-warning); box-shadow: 0 0 0 2px var(--c-warning); }
.timeline-time { font-size: var(--fz-xs); color: var(--c-text-4); }
.timeline-content { font-size: var(--fz-sm); color: var(--c-text-1); margin-top: 2px; }

/* --- Empty State --- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--c-text-4); }
.empty-state svg { width: 64px; height: 64px; margin-bottom: 12px; opacity: 0.4; }

/* --- Grid Utility --- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }
.text-sm { font-size: var(--fz-sm); }
.text-xs { font-size: var(--fz-xs); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--c-text-3); }
.font-bold { font-weight: 600; }
.whitespace-nowrap { white-space: nowrap; }

/* --- Login Page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0c2340 0%, #1a4a8a 50%, #2d6bdd 100%);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  top: -200px; right: -100px;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
  bottom: -100px; left: -80px;
}
.login-box {
  position: relative;
  z-index: 1;
  width: 400px;
  max-width: 90vw;
  background: rgba(255,255,255,0.95);
  border-radius: var(--r-xl);
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-title { font-size: var(--fz-2xl); font-weight: 700; color: var(--c-primary-dark); text-align: center; margin-bottom: 4px; }
.login-subtitle { font-size: var(--fz-sm); color: var(--c-text-3); text-align: center; margin-bottom: 32px; }
.login-btn { width: 100%; padding: 12px; font-size: var(--fz-md); }

/* --- Data Screen --- */
.data-screen {
  background: #061327;
  min-height: 100vh;
  color: #c7d6e8;
  padding: 16px;
}
.data-screen-header {
  text-align: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(45,107,221,0.2);
  margin-bottom: 16px;
}
.data-screen-title { font-size: 28px; font-weight: 700; color: #fff; letter-spacing: 4px; }
.data-screen-grid { display: grid; grid-template-columns: 1fr 1.5fr 1fr; gap: 16px; }
.ds-card {
  background: rgba(12,35,64,0.6);
  border: 1px solid rgba(45,107,221,0.15);
  border-radius: var(--r-md);
  padding: 16px;
}
.ds-card-title { font-size: var(--fz-sm); color: #8aa5c9; margin-bottom: 12px; padding-left: 10px; border-left: 3px solid var(--c-primary-light); }
.ds-metric { font-size: 32px; font-weight: 700; color: #25e6d4; }
.ds-metric-label { font-size: var(--fz-xs); color: #8aa5c9; margin-top: 4px; }

/* Responsive */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar-logo .logo-text, .sidebar-item span:not(.nav-icon) { display: none; }
  .main-area { margin-left: 64px; }
  .stats-grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
