/* ===== 政务风格基础变量 ===== */
:root {
  --primary: #1a5276;
  --primary-light: #2980b9;
  --primary-dark: #0e3d5c;
  --accent: #c0392b;
  --accent-light: #e74c3c;
  --bg: #f0f2f5;
  --bg-white: #ffffff;
  --sidebar-bg: #1a3a5c;
  --sidebar-active: rgba(255,255,255,0.15);
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --text-white: #ecf0f1;
  --border: #dce1e6;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #e74c3c;
  --info: #3498db;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 4px;
}

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

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

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
}

.login-box {
  background: white;
  border-radius: 8px;
  padding: 40px;
  width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-header h1 {
  font-size: 22px;
  color: var(--primary);
  margin-bottom: 6px;
}

.login-header p {
  color: var(--text-light);
  font-size: 13px;
}

.login-header .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

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

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(41,128,185,0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

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

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: var(--accent-light); }

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }

.login-btn { width: 100%; padding: 12px; font-size: 16px; margin-top: 10px; }

.login-error {
  color: var(--danger);
  text-align: center;
  margin-bottom: 10px;
  font-size: 13px;
  min-height: 20px;
}

/* ===== MAIN LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: var(--text-white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

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

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.sidebar-header .sub {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 4px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 14px;
  border-left: 3px solid transparent;
}

.nav-item:hover { background: var(--sidebar-active); }
.nav-item.active {
  background: var(--sidebar-active);
  border-left-color: var(--primary-light);
}

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

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

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.user-detail {
  flex: 1;
  min-width: 0;
}

.user-detail .name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-detail .role {
  font-size: 11px;
  opacity: 0.7;
}

.logout-btn {
  width: 100%;
  padding: 8px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--text-white);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.2s;
}

.logout-btn:hover { background: rgba(255,255,255,0.2); }

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  margin-left: 220px;
  min-height: 100vh;
}

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

.page-header h2 {
  font-size: 20px;
  color: var(--primary-dark);
}

.page-header .breadcrumb {
  font-size: 13px;
  color: var(--text-light);
}

.page-body {
  padding: 20px 24px;
}

/* ===== CARDS ===== */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

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

.card-header h3 {
  font-size: 16px;
  color: var(--primary-dark);
}

.card-body {
  padding: 20px;
}

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
  min-width: 800px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  border-left: 4px solid var(--primary);
}

.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.info { border-left-color: var(--info); }

.stat-icon {
  font-size: 36px;
  opacity: 0.8;
}

.stat-content .number {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1;
}

.stat-content .label {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

/* ===== TABLE ===== */
.table-wrapper {
  overflow-x: auto;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

table th, table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
}

table th {
  background: #f8f9fa;
  font-weight: 600;
  color: var(--text);
  position: sticky;
  top: 0;
  white-space: nowrap;
}

table tr:hover { background: #f5f8fc; }

table td .actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

table th:nth-child(1), table td:nth-child(1) { width: 50px; text-align: center; }
table th:nth-child(2), table td:nth-child(2) { width: 80px; white-space: nowrap; }
table th:nth-child(3), table td:nth-child(3) { width: 150px; }
table th:nth-child(4), table td:nth-child(4) { width: 70px; text-align: center; white-space: nowrap; }
table th:nth-child(5), table td:nth-child(5) { width: 80px; white-space: nowrap; }
table th:nth-child(6), table td:nth-child(6) { width: 110px; white-space: nowrap; }
table th:nth-child(7), table td:nth-child(7) { width: 80px; white-space: nowrap; }
table th:nth-child(8), table td:nth-child(8) { width: 110px; white-space: nowrap; }
table th:nth-child(9), table td:nth-child(9) { width: 80px; white-space: nowrap; }
table th:nth-child(10), table td:nth-child(10) { width: 110px; white-space: nowrap; }
table th:nth-child(11), table td:nth-child(11) { width: 120px; }

table td:nth-child(3):hover { overflow: visible; white-space: normal; word-break: break-all; position: relative; z-index: 1; background: white; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

/* ===== STATUS BADGES ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-normal { background: #e8f5e9; color: #2e7d32; }
.badge-stopped { background: #fce4ec; color: #c62828; }
.badge-notstarted { background: #fff3e0; color: #e65100; }
.badge-building { background: #e3f2fd; color: #1565c0; }
.badge-admin { background: #e8eaf6; color: #283593; }
.badge-worker { background: #f3e5f5; color: #6a1b9a; }

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.filter-bar .search-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
}

.filter-bar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  background: white;
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
}

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

.pagination button:hover:not(:disabled) { background: var(--bg); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination .current { background: var(--primary); color: white; border-color: var(--primary); }
.pagination .info { font-size: 13px; color: var(--text-light); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.show { opacity: 1; pointer-events: all; }

.modal {
  background: white;
  border-radius: 8px;
  width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

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

.modal-header h3 { font-size: 16px; }

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-light);
  padding: 4px 8px;
}

.modal-body { padding: 20px; }

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ===== CHART AREA ===== */
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.chart-placeholder {
  height: 320px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0;
}

.bar-chart-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bar-chart-item .label {
  width: 80px;
  text-align: right;
  font-size: 12px;
  color: var(--text);
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-chart-item .bar-wrapper {
  flex: 1;
  height: 24px;
  background: #f0f2f5;
  border-radius: 12px;
  overflow: hidden;
}

.bar-chart-item .bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 11px;
  color: white;
  font-weight: 600;
  min-width: 30px;
  transition: width 0.6s ease;
}

.bar-chart-item .bar.warning { background: linear-gradient(90deg, #f39c12, #f1c40f); }
.bar-chart-item .bar.danger { background: linear-gradient(90deg, #e74c3c, #c0392b); }
.bar-chart-item .bar.success { background: linear-gradient(90deg, #27ae60, #2ecc71); }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: white;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  animation: toastIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .nav-text, .sidebar-header h2, .sidebar-header .sub,
  .user-detail, .logout-btn { display: none; }
  .sidebar-header { padding: 12px 8px; }
  .nav-item { justify-content: center; padding: 12px; }
  .nav-item .nav-icon { font-size: 20px; }
  .main-content { margin-left: 60px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .chart-row { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .modal { width: 95%; margin: 10px; }
}
