/* ===== GodaSmartCard – Dashboard ===== */
#view-dashboard .dash-page {
  animation: dashFadeIn 0.4s ease both;
}

@keyframes dashFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* KPI grid – 4 cột đều trên desktop */
#view-dashboard .kpi-grid,
#view-dashboard .dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

#view-dashboard .kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
  animation: dashFadeIn 0.45s ease both;
}

#view-dashboard .kpi-card:nth-child(1) { animation-delay: 0.04s; }
#view-dashboard .kpi-card:nth-child(2) { animation-delay: 0.08s; }
#view-dashboard .kpi-card:nth-child(3) { animation-delay: 0.12s; }
#view-dashboard .kpi-card:nth-child(4) { animation-delay: 0.16s; }

#view-dashboard .kpi-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-2);
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.5);
}

#view-dashboard .kpi-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  opacity: 0.12;
  pointer-events: none;
}

#view-dashboard .kpi-card.blue::before { background: var(--info); }
#view-dashboard .kpi-card.green::before { background: var(--success); }
#view-dashboard .kpi-card.purple::before { background: #8b5cf6; }
#view-dashboard .kpi-card.pink::before { background: #e91e8c; }

#view-dashboard .kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

#view-dashboard .kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 17px;
  color: #fff;
  position: relative;
  z-index: 1;
}

#view-dashboard .kpi-icon.blue {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}
#view-dashboard .kpi-icon.green {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  box-shadow: 0 6px 16px rgba(34, 197, 94, 0.35);
}
#view-dashboard .kpi-icon.purple {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.35);
}
#view-dashboard .kpi-icon.pink {
  background: linear-gradient(135deg, #e91e8c, #f472b6);
  box-shadow: 0 6px 16px rgba(233, 30, 140, 0.35);
}

#view-dashboard .kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  position: relative;
  z-index: 1;
}

#view-dashboard .kpi-trend.up {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

#view-dashboard .kpi-trend.down {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

#view-dashboard .kpi-trend i { font-size: 9px; }

#view-dashboard .kpi-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 4px;
  position: relative;
  z-index: 1;
}

#view-dashboard .kpi-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  position: relative;
  z-index: 1;
}

#view-dashboard .dash-chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

#view-dashboard .dash-chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

#view-dashboard .dash-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

#view-dashboard .dash-chart-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

#view-dashboard .dash-chart-title i {
  color: var(--brand);
  font-size: 14px;
}

#view-dashboard .chart-filter {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

#view-dashboard .chart-filter-btn {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
  transition: all 0.2s;
  letter-spacing: 0.02em;
}

#view-dashboard .chart-filter-btn:hover {
  color: var(--text);
  background: var(--surface-3);
}

#view-dashboard .chart-filter-btn.active {
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

#view-dashboard .chart-container {
  position: relative;
  height: 300px;
}

#view-dashboard .chart-container.donut {
  height: 260px;
}

#view-dashboard .activity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 8px;
}

#view-dashboard .activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

#view-dashboard .activity-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

#view-dashboard .activity-title i {
  color: var(--brand);
  font-size: 14px;
}

#view-dashboard .activity-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(34, 197, 94, 0.15);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#view-dashboard .activity-live::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  animation: dashPulse 2s infinite;
}

@keyframes dashPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  50% { opacity: 0.6; box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}

#view-dashboard .activity-table-wrap {
  max-height: 380px;
  overflow-y: auto;
}

#view-dashboard .activity-table {
  width: 100%;
  border-collapse: collapse;
}

#view-dashboard .activity-table th {
  text-align: left;
  padding: 12px 24px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}

#view-dashboard .activity-table td {
  padding: 14px 24px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

#view-dashboard .activity-table tr:last-child td { border-bottom: none; }

#view-dashboard .activity-table tbody tr {
  transition: background 0.2s;
}

#view-dashboard .activity-table tbody tr:hover td {
  background: var(--surface-2);
}

#view-dashboard .activity-table tbody tr.new-row {
  animation: dashNewRow 0.6s cubic-bezier(.2, .8, .2, 1);
}

@keyframes dashNewRow {
  from {
    opacity: 0;
    transform: translateX(-16px);
    background: rgba(99, 102, 241, 0.15);
  }
  to {
    opacity: 1;
    transform: translateX(0);
    background: transparent;
  }
}

#view-dashboard .event-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

#view-dashboard .dash-event-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12px;
  flex-shrink: 0;
}

#view-dashboard .dash-event-icon.qr { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
#view-dashboard .dash-event-icon.save { background: rgba(34, 197, 94, 0.15); color: var(--success); }
#view-dashboard .dash-event-icon.share { background: rgba(59, 130, 246, 0.15); color: var(--info); }
#view-dashboard .dash-event-icon.nfc { background: rgba(6, 182, 212, 0.15); color: #06b6d4; }
#view-dashboard .dash-event-icon.view { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

#view-dashboard .event-name { font-weight: 600; }

#view-dashboard .source-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

#view-dashboard .source-badge i { font-size: 10px; }

#view-dashboard .time-cell {
  color: var(--text-muted);
  font-size: 12.5px;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  #view-dashboard .dash-chart-grid { grid-template-columns: 1fr; }
  #view-dashboard .kpi-grid,
  #view-dashboard .dash-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  #view-dashboard .kpi-grid,
  #view-dashboard .dash-kpi-grid {
    grid-template-columns: 1fr;
  }
  #view-dashboard .chart-container { height: 240px; }
  #view-dashboard .activity-table th:nth-child(3),
  #view-dashboard .activity-table td:nth-child(3) { display: none; }
}
