:root {
  --primary: #1565c0;
  --primary-light: #42a5f5;
  --primary-dark: #0d47a1;
  --secondary: #667eea;
  --accent: #0288d1;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --text: #1f2937;
  --text-light: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --gradient: linear-gradient(135deg, #0c4a8a 0%, #1565c0 40%, #1976d2 70%, #0288d1 100%);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

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

.sidebar {
  width: 64px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: width 0.3s ease;
  box-shadow: 2px 0 8px rgba(0,0,0,0.03);
}
.sidebar:hover { width: 200px; }

.sidebar-header {
  margin-bottom: 24px;
  padding: 0 16px;
  width: 100%;
  opacity: 0;
  transition: opacity 0.3s ease;
  overflow: hidden;
}
.sidebar:hover .sidebar-header { opacity: 1; }

.sidebar-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.sidebar-header .logo span:first-child { font-size: 20px; }
.sidebar-header .logo span:last-child { font-size: 14px; font-weight: 600; color: var(--primary); }

.sidebar-menu {
  list-style: none;
  width: 100%;
  padding: 0 6px;
  flex: 1;
}
.sidebar-menu li { margin-bottom: 4px; }
.sidebar-menu li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-light);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.sidebar-menu li a:hover { background: rgba(21, 101, 192, 0.08); color: var(--primary); }
.sidebar-menu li a.active { background: rgba(21, 101, 192, 0.12); color: var(--primary); font-weight: 600; }
.sidebar-menu li a span:first-child { width: 20px; font-size: 15px; flex-shrink: 0; text-align: center; }
.sidebar-menu li a span:last-child { opacity: 0; transition: opacity 0.3s ease; }
.sidebar:hover .sidebar-menu li a span:last-child { opacity: 1; }
.sidebar-divider { height: 1px; background: var(--border); margin: 6px 14px; opacity: 0; transition: opacity 0.3s; }
.sidebar:hover .sidebar-divider { opacity: 1; }

.sidebar-user {
  padding: 12px;
  border-top: 1px solid var(--border);
  margin-top: auto;
  opacity: 0;
  transition: opacity 0.3s ease;
  overflow: hidden;
  pointer-events: none;
}
.sidebar:hover .sidebar-user {
  opacity: 1;
  pointer-events: auto;
}
.admin-item { border-top: 2px solid #e8f4fd !important; }
.admin-item span:first-child { color: #f59e0b !important; }

.main { flex: 1; margin-left: 64px; min-height: 100vh; }

.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 90;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.header-left h1 { font-size: 17px; font-weight: 600; color: var(--text); }
.header-left .date-badge {
  padding: 4px 10px;
  background: rgba(21, 101, 192, 0.08);
  border-radius: 16px;
  font-size: 12px;
  color: var(--primary);
}
.header-right { display: flex; align-items: center; gap: 14px; }

.search-box { position: relative; }
.search-box input {
  width: 180px;
  padding: 7px 10px 7px 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  background: var(--bg);
  color: var(--text);
  transition: all 0.2s;
}
.search-box input:focus { outline: none; border-color: var(--primary); width: 240px; }
.search-box input::placeholder { color: var(--text-muted); }
.search-box .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 12px;
  pointer-events: none;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: rgba(21, 101, 192, 0.08);
  border-radius: 16px;
}
.user-info .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
}
.user-info .name { font-size: 12px; font-weight: 500; display: none; }
.header-right:hover .user-info .name { display: block; }

.content { padding: 20px; }

.card {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 20px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--text); }

.chart-card {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 20px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
}
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.chart-header h3 { font-size: 15px; font-weight: 600; color: var(--text); }

.chart-tabs { display: flex; gap: 5px; }
.chart-tab {
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  background: var(--bg);
  color: var(--text-light);
  border: none;
  transition: all 0.2s;
}
.chart-tab:hover { background: rgba(21, 101, 192, 0.08); }
.chart-tab.active { background: var(--primary); color: #fff; }

.hero-section {
  background: var(--gradient);
  border-radius: 14px;
  padding: 32px;
  color: #fff;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.hero-section::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -40px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.1), transparent 70%);
}
.hero-content { position: relative; z-index: 1; }
.hero-badge {
  display: inline-block;
  padding: 4px 14px;
  background: rgba(255,255,255,0.15);
  border-radius: 20px;
  font-size: 12px;
  margin-bottom: 12px;
}
.hero-section h2 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.hero-section p { font-size: 13px; color: rgba(255,255,255,0.8); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-item {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 18px 16px;
  border: 1px solid var(--border);
}
.kpi-item .kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 10px;
}
.kpi-item .kpi-label { font-size: 11px; color: var(--text-light); font-weight: 500; margin-bottom: 4px; }
.kpi-item .kpi-value { font-size: 24px; font-weight: 800; line-height: 1.1; }
.kpi-item .kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.kpi-blue .kpi-icon { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #2563eb; }
.kpi-blue .kpi-value { color: #1d4ed8; }
.kpi-green .kpi-icon { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #059669; }
.kpi-green .kpi-value { color: #047857; }
.kpi-red .kpi-icon { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #dc2626; }
.kpi-red .kpi-value { color: #b91c1c; }
.kpi-amber .kpi-icon { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #d97706; }
.kpi-amber .kpi-value { color: #b45309; }
.kpi-purple .kpi-icon { background: linear-gradient(135deg, #ede9fe, #ddd6fe); color: #7c3aed; }
.kpi-purple .kpi-value { color: #6d28d9; }
.kpi-pink .kpi-icon { background: linear-gradient(135deg, #fce7f3, #fbcfe8); color: #db2777; }
.kpi-pink .kpi-value { color: #be185d; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead tr { background: #f0f4ff; }
.data-table th {
  padding: 8px 10px;
  border-bottom: 2px solid #ddd;
  text-align: center;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text);
}
.data-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #eee;
  text-align: center;
}
.data-table tbody tr:nth-child(even) { background: #f9fafb; }
.data-table tbody tr:nth-child(odd) { background: #fff; }
.data-table .text-danger { color: #dc2626; font-weight: 700; }
.data-table .text-warning { color: #d97706; font-weight: 700; }
.data-table .text-success { color: #16a34a; font-weight: 700; }
.data-table .text-primary { color: #2563eb; font-weight: 700; }
.data-table .text-bold { font-weight: 700; }
.data-table th[data-sort] { cursor: pointer; user-select: none; }
.data-table th[data-sort]:hover { background: #e0e7ff; }
.data-table th.sort-asc::after { content: ' ↑'; font-size: 10px; color: var(--primary); }
.data-table th.sort-desc::after { content: ' ↓'; font-size: 10px; color: var(--primary); }

.insight-box {
  background: #f0f7ff;
  border-left: 4px solid #667eea;
  padding: 12px 16px;
  margin: 14px 0 0;
  border-radius: 0 8px 8px 0;
  color: #444;
  font-size: 13px;
}
.insight-danger {
  background: #fef2f2;
  border-left-color: #dc2626;
  color: #1e3a5f;
}
.insight-warning {
  background: #fefce8;
  border-left-color: #ca8a04;
  color: #1e3a5f;
}
.insight-success {
  background: #f0fdf4;
  border-left-color: #16a34a;
  color: #1e3a5f;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
  border: none;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { border: 1px solid var(--border); color: var(--text-light); background: #fff; }
.btn-outline:hover { background: #f8fafc; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 8px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-info { background: #dbeafe; color: #2563eb; }
.badge-muted { background: #f1f5f9; color: #64748b; }

.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar select,
.filter-bar input {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  background: #fff;
  color: var(--text);
}
.filter-bar select:focus,
.filter-bar input:focus { outline: none; border-color: var(--primary); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
  color: var(--text-muted);
}
.loading-spinner::after {
  content: '';
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state .title { font-size: 16px; font-weight: 600; color: var(--text-light); margin-bottom: 8px; }
.empty-state .desc { font-size: 13px; }

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: 60px;
    bottom: auto;
    flex-direction: row;
    padding: 0 8px;
    overflow-x: auto;
  }
  .sidebar:hover { width: 100%; }
  .sidebar-header { display: none; }
  .sidebar-menu {
    display: flex;
    padding: 0;
    width: auto;
    flex-direction: row;
  }
  .sidebar-menu li a {
    flex-direction: column;
    gap: 3px;
    padding: 10px 14px;
  }
  .sidebar-menu li a span:last-child { font-size: 10px; opacity: 1; }
  .sidebar-user { display: none; }
  .main { margin-left: 0; margin-top: 60px; }
  .content { padding: 12px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .header { padding: 10px 14px; }
  .header-right .search-box { display: none; }
}

.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: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
}
.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.9) translateY(-20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-container.active {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 16px 16px 0 0;
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  transition: all 0.2s;
}
.modal-close:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(90vh - 80px);
}

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  animation: slideInRight 0.3s ease;
  min-width: 280px;
  max-width: 400px;
}
.toast.fade-out {
  animation: slideOutRight 0.3s ease forwards;
}

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

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

.toast-success {
  border-left: 4px solid var(--success);
  background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
}
.toast-error {
  border-left: 4px solid var(--danger);
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}
.toast-warning {
  border-left: 4px solid var(--warning);
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}
.toast-info {
  border-left: 4px solid var(--primary);
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}
.toast-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(8px);
}
.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.loading-spinner {
  text-align: center;
  padding: 40px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

.loading-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-top: 12px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  transition: all 0.2s;
  outline: none;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.1);
}
.form-input.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  line-height: 1;
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 2px 8px rgba(21, 101, 192, 0.25);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(21, 101, 192, 0.35);
}

.btn-outline {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover:not(:disabled) {
  background: var(--bg);
  border-color: var(--primary-light);
  color: var(--primary);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #dc2626);
  color: #fff;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}
.btn-danger:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

@media (max-width: 768px) {
  .modal-container {
    width: 95%;
    margin: 10px;
  }

  .toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }

  .toast {
    min-width: auto;
    max-width: none;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-header {
    padding: 16px 20px;
  }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead tr {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 2px solid var(--border);
}
.data-table th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-light);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.data-table tbody tr {
  border-bottom: 1px solid #f0f0f0;
  transition: all 0.2s;
}
.data-table tbody tr:hover {
  background: #fafbfc;
}
.data-table td {
  padding: 12px 14px;
  color: var(--text);
}
