:root {
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --text: #222;
  --muted: #666;
  --border: #e2e6ef;
  --primary: #667eea;
  --primary-dark: #5568d3;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  --shadow-strong: 0 4px 15px rgba(102, 126, 234, 0.2);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
}

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

body {
  font-family: 'Microsoft JhengHei', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.dashboard {
  max-width: 1900px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 18px 22px;
  background: var(--header-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
  border-radius: 10px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-strong);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.header h1 {
  color: #fff;
  font-size: 24px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.last-update {
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.refresh-indicator {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.refresh-indicator.active {
  display: inline-block;
}

.refresh-success {
  color: #22c55e;
  display: none;
}

.refresh-success.active {
  display: inline-block;
  animation: fadeOut 1s ease-out forwards;
}

.refresh-error {
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  display: none;
}

.refresh-error.active {
  display: inline-block;
}

.btn {
  padding: 9px 20px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-light {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.btn-light:hover {
  background: rgba(255, 255, 255, 0.3);
}

.btn-back {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-back:hover {
  background: rgba(255, 255, 255, 0.25);
}

.btn-primary,
.btn-secondary {
  padding: 9px 20px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

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

.btn-secondary {
  background: #6c757d;
  color: #fff;
}

.btn-secondary:hover {
  background: #5a6268;
}

.summary-row {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.summary-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 16px 20px;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.summary-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.summary-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  transition: all 0.3s ease;
}

.summary-value.updated {
  animation: valueUpdate 0.5s ease;
}

.summary-value.small {
  font-size: 20px;
}

.filter-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--primary);
  background: #e8ecff;
  padding: 4px 12px;
  border-radius: 4px;
}

.filter-indicator .clear-btn {
  cursor: pointer;
  font-weight: 700;
}

.filter-indicator .clear-btn:hover {
  color: var(--danger);
}

.placeholder {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.pagination button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.pagination button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

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

.pagination .page-info {
  font-size: 13px;
  color: var(--muted);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.loading-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 10px;
}

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

@keyframes fadeOut {
  0% {
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes valueUpdate {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
    background: rgba(102, 126, 234, 0.1);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 1400px) {
  .summary-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1000px) {
  .summary-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .dashboard {
    padding: 16px;
  }

  .summary-row {
    grid-template-columns: 1fr;
  }

  .header {
    padding: 14px 16px;
  }

  .header h1 {
    font-size: 20px;
  }
}
